0

How to get application attribute in declarative? I used this code, but it is not working.

<%!
     TestValues tvtemp = TestValues application.getAttribute("tv1");
%>

Error details:

    PWC6199: Generated servlet error:
    cannot find symbol
    symbol:   variable application
Malwinder Singh
  • 6,324
  • 14
  • 60
  • 96

1 Answers1

0

If you are trying to cast the getAttribute() values to the TestValues class . import it on the jsp you are using it and syntax should be ,

 <%!    
    TestValues tvtemp = (TestValues) application.getAttribute("tv1");
  %>

However srcriplets are discouraged over the decades and should be avoided . You can use the jstl and el .

Read How to avoid Java code in JSP files?

Community
  • 1
  • 1
Santhosh
  • 8,131
  • 3
  • 28
  • 56