• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JSP error because of a qouted value insied a qoute.

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,

Tomcat will not allow this because of error:

org.apache.jasper.JasperException: /TestBean.jsp(20,10) Attribute value request.getParameter('userName') is quoted with ' which must be escaped when used within the value
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:41)



<code=jsp>

<jsp:setProperty name="person" property="name"
value="<%= request.getParameter("userName")%>" />

</code>

Any ideas? I found a solution but i could not understand it...

For tomcat, this is the reason.... Where to find that settings in tomcat Catalina?

STRICT_QUOTE_ESCAPING as true where as

6.0.20 treats STRICT_QUOTE_ESCAPING as false.




regards,
Vic
 
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is not a Tomcat problem.

You are, in effect, coding a string in the form of "this is "a" string" and the inner quotes are causing the lexical scanner to become confused because there's no unambiguous way to know that they are inner quotes instead of terminal quotes. As in "this is" + a + "string".

You need to disambiguate the text, and you should be able to do that using escapes. In Java, that would be "this is \"a\" string".
 
victor chiong
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Paul,

This is what you mean?

value="<%= request.getParameter(\"userName\")%>" /> ?
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JSP is like HTML. (But you knew that already, right?)

In particular JSP is like HTML in that you can use either the quote character (") or the apostrophe character (') to delimit attribute values.
 
victor chiong
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have tried both ' and " and it ends up in error.... Or maybe we are not on the same point?


Anyway.. I just paste the value = false on the catalina server config.. Then it now allows it... But i don't know if that is the standard...
 
victor chiong
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know basic html from w3schools... I will review what you mean..
 
Sheriff
Posts: 67746
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
Problems like this can be completely avoided by not using obsolete and discredited scriptlets on your JSP pages.

Using the EL, the fragment would be: value="${params.userName}"

There are many good reasons that scriptlets are discredited; this is just one of them.

Please read this JspFaq entry.
 
victor chiong
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bear,

Thank you very much. I will try that too I am studying JEE by Head First. Thanks for helping me guys.. I really want to learn this stuff

regards,
Vic
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic