Win a copy of Fixing your Scrum this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

Checking the existence of a Context Environment variable

 
Ranch Hand
Posts: 58
MyEclipse IDE Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67579
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
What do you have to say for yourself? Hmmm? Anything? And you call yourself a tiny ad.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic