Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Weird JSTL Behavior

 
Luke Shannon
Ranch Hand
Posts: 239
  • 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
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65535
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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
Author and ninkuma
Marshal
Posts: 65535
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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: 239
  • 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
Author and ninkuma
Marshal
Posts: 65535
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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: 239
  • 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!