-1

I have a java class like this :

class Constans {
    public static final String FIELD = "example";
}
model.addAttribute(Constants.FIELD, 11);

Now on the jsp page I just want to use like this to access :

<c:out value="${requestScope.Constants.FIELD}"/>

How should I do?

ɢʀᴜɴᴛ
  • 32,025
  • 15
  • 116
  • 110
z3jjlzt
  • 1
  • 2

1 Answers1

-2

You have to save this object fe. in session scope:
setAttribute("FIELD", Constans.FIELD)
you can set this in servlet and call EL expression in jsp page:
${FIELD}

You can add to session or request only object. Not a class. https://tomcat.apache.org/tomcat-5.5-doc/servletapi/javax/servlet/http/HttpSession.html#setAttribute(java.lang.String, java.lang.Object)

Kutti
  • 486
  • 1
  • 6
  • 17
  • 1
    Hi, we're not in 1999 anymore. To catch up I suggest to read the answer in the duplicate as well. – BalusC Aug 31 '17 at 11:01