• Post Reply Bookmark Topic Watch Topic
  • New Topic

Checking the existence of a Context Environment variable

 
B. Katz
Ranch Hand
Posts: 53
Chrome Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greetings,

It seems to me from the way that it was described in the "Essential JSP Expression Language" RefCardz on dzone.com that I should be able to use the "empty" operator to safely check the existence of a Context Environment variable. Am I reading that right?

Basically, my thought is something like this:
Given that *if* the variable "thisvar" exists in WEB-INF/web.xml in a Tomcat webapp, it would be defined as follows:

Then, from the JSP page, I should be able to check if it *does* exist, and if so, use it with something like this:


Does this seem right, or am I way off-base here?

TIA for your help.


Regards,

Katz
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like you are trying to embed EL expressions inside a Java string inside Java code? That's not going to work. The JSTL and EL are meant to work directly inside JSP pages without any Java code.

In any case, I'm not sure that the EL automatically exposes env entries to begin with. If you need access from a JSP, you may need to write a bean that gathers the information and exposes it through properties so that the EL can access it.

If you need access from Java code, the EL is not in the picture.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!