Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Error getting variable from java class  RSS feed

 
Brock Awadmay
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an older webapp and just recently have been trying to upgrade it to use JSP 2.0 spec

I have a java Class named Constants (not a javabean) contains

public static final boolean DEBUG = true; //or false if I don't want debug messages to appear throughout web app

I have a jsp, an in that jsp I would like to use DEBUG as

<c:if test="${Constants.DEBUG}"> <%-- this does not work I get a compile error, but is off somewhere in jar file class and library I am unfamiliar with--%>

i then tried

<c:set var="debug" value="<%= Constanst.DEBUG%>" />
<c:if test="${debug == true}">
<%-- once again this does not work --%>

I am rather new to JSTL, EL, and JSP 2.0 and would appreciate any advice in accessing the variable from the class, and perhaps an explanation of why things are not working.

I feel I am at a point where I know enough JSTL, EL, and JSP to use them, but to cause problems (be dangerous) but not enought to fix the problems I cause.
 
Brock Awadmay
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
slight modification to what I said before
<c:set var="debug" value="${Constants.DEBUG}" /> <%-- compiles, but returns the value "class" --%>
<c:if test="${debug == true}"> <%--thus evaluates to false, and is not correct--%>

I would expect that <c:if test="${Constants.DEBUG}"> is performing the same way

actually the compile error I mentioned before occurs in <c:if test="${<%=Constants.DEBUG%>}" />

(probably from mixing servlets and jstl)

once agian can someone explain why

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66203
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This article explains all.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!