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,644
  • 14
  • 65
  • 103

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,181
  • 4
  • 29
  • 56