wood burning stoves 2.0*
The moose likes Tomcat and the fly likes JSP error because of a qouted value insied a qoute. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "JSP error because of a qouted value insied a qoute." Watch "JSP error because of a qouted value insied a qoute." New topic
Author

JSP error because of a qouted value insied a qoute.

victor chiong
Ranch Hand

Joined: Apr 04, 2012
Posts: 73
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
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16058
    
  21

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".


Customer surveys are for companies who didn't pay proper attention to begin with.
victor chiong
Ranch Hand

Joined: Apr 04, 2012
Posts: 73
Hi Paul,

This is what you mean?

value="<%= request.getParameter(\"userName\")%>" /> ?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

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

Joined: Apr 04, 2012
Posts: 73
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

Joined: Apr 04, 2012
Posts: 73
I know basic html from w3schools... I will review what you mean..
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61202
    
  66

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
victor chiong
Ranch Hand

Joined: Apr 04, 2012
Posts: 73
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP error because of a qouted value insied a qoute.