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

Custom tag: attribute cannot contain quote?  RSS feed

 
D. Ogranos
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a current project, I created a custom tag to create menu items in a jsp. In the .tld, I set all attributes for the tag to have the value "rtexprvalue=true".

Now I'm trying pass a scriptlet expression to an attribute (don't bite me, >I< didn't wish to use scriptlets!):



When trying to load the page, an exception is thrown:
Attribute value currentSetting.equals("values") is quoted with " which must be escaped when used within the value

What does this mean? The quotes around "values"? How can I escape them here? I also tried storing the value in another variable, that works. But I'd rather keep the expression just where it is needed..
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66205
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just as with Java, you need to escape embedded quotes or the parse can't know whether the quote is text or the closing delimiter. You could alternatively using single quotes for the outer quotes.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why mix scriptlets with tags anyway?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66205
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Masochism is the only explanation.
 
D. Ogranos
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd say dynamic attribute values are the better explanation

Anyway, I wrote the expression as currentSettings.equals(\"values\") and it works now. Looks very strange to me, but apparently its right. So thanks for the help!
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
D. Ogranos wrote:I'd say dynamic attribute values are the better explanation

Not a good one, though; you should be using JSP EL.
 
D. Ogranos
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:Not a good one, though; you should be using JSP EL.


See my original post...I'd much prefer using EL, but unfortunately I do not have the say in the project. Tried and argued, but to no avail
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66205
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I feel your pain.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That makes no sense: EL exists whether or not you're using it.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:I feel your pain.

And it sustains me.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!