Win a copy of Event Streams in Action this week in the Java in General 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Weird JSTL Behavior

 
Ranch Hand
Posts: 240
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a variable in JSTL not being replaced with its value and I don't know why.

Here is what I mean:

This is in the JSP page:



Here is what get produced when the page runs:



I can't understand why the first variable is being replaced and the second one isn't?

But if I change the direction of the last slash:

JSP:




I get this in HTML:



Any idea what is going on here?

Thanks,

Luke
 
Marshal
Posts: 67275
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Placing the backslash before the $ escapes it (similar to the way that \" esdapes a quote character in a Java string literal). It is the supported mechanism to emit the sequence ${ without interpretation.
 
Bear Bibeault
Marshal
Posts: 67275
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<terminology-police-alert>

a variable in JSTL



should really be "a variable in the EL"

</terminology-police-alert>
 
Luke Shannon
Ranch Hand
Posts: 240
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the terminology correction.

Concerning the escape character, I thought it might be something like this.

What confuses me is that it works if this case:



But not here:


Is this because there is a literal string proceeding the slash in the second example?

In production this shouldn't matter, it runs on Linux so the slashes are all forward. But I would like to get this working in window.

I will try putting 'thumbnails' into a EL variable, also I would put the file seperator (\ vs. /) in the Web.xml in a param called fileSeperator. This way I could obtain it using application.getInitParameter("fileSeperator").

Hopefully this will fix the issue.

Thanks,


Luke
[ August 11, 2005: Message edited by: Luke Shannon ]
 
Bear Bibeault
Marshal
Posts: 67275
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

But I would like to get this working in window.



I've never seen a case where using forward slashes didn't work in Windows. Java is smart that way.
[ August 11, 2005: Message edited by: Bear Bibeault ]
 
Luke Shannon
Ranch Hand
Posts: 240
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are correct. Here is the code that works and the HTML produced.

Thanks for following this through with me.

JSP:



HTML result:

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!