You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Darryl Stoflet <ds...@calweb.com> on 2000/03/24 16:41:26 UTC

Invalid Escape character '?' Bug in SetPropertyGenerator?

       Running Tomcat 3.1 built from source yesterday. The following jsp
fragment:

<jsp:setProperty name="dbbean" property="url" value="jdbc:inetdae:MANTRA?database=pubs" />

is converted to:

JspRuntimeLibrary.introspecthelper(pageContext.findAttribute("dbbean"),"url","jdbc:inetdae:MANTRA\?database=pubs",null,null,
false);

during the JSP compilation process. Notice that the '?' is escaped 
with a singe backslash. This then fails during the compile do to 
the invalid escape char. The error is below. What can I do so to 
use characters like ? and * within the value attribute? Or is
this a bug?

I tracked this down to org.apache.jasper.compiler.SetPropertyGenerator
and the generate method below:

generate(ServletWriter writer, Class phase)
...
// value is a constant.
if (!JspUtil.isExpression (value)) {
	writer.println("JspRuntimeLibrary.introspecthelper(pageContext." +
		       "findAttribute(\"" + name + "\"), \"" + property +
		       "\",\"" + JspUtil.escapeQueryString(value) +
		       "\",null,null, false);");

So the org.apache.jasper.compiler.JspUtil.escapeQueryString method escapes
various chars one of which is '?' which obviously causes the problem I 
am encountering. The question I have is why? And it obviously is not
doing what it was intended to do because it flat out wont compile under
javac now. Can anyone explain the reasoning for calling escapeQueryString
on a value attribute within setProperty? I've included the stack trace
below.



Internal Servlet Error:

org.apache.jasper.JasperException: Unable to compile class for
JSPwork\localhost_8080%2Fexamples\_0002fAuthorList_0002ejspAuthorList_jsp_6.java:95:
Invalid escape character.
                JspRuntimeLibrary.introspecthelper(pageContext.findAttribute("dbbean"),
"url","jdbc:inetdae:MANTRA\?database=pubs",null,null, false);

^
1 error

        at org.apache.jasper.compiler.Compiler.compile(Compiler.java:240)
        at org.apache.jasper.runtime.JspServlet.loadJSP(JspServlet.java:412)
        at

org.apache.jasper.runtime.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:147)
        at
org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.java:159)
        at org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:259)
        at org.apache.jasper.runtime.JspServlet.service(JspServlet.java:367)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
        at org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:390)
        at org.apache.tomcat.core.ContextManager.service(ContextManager.java:529)
        at

org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:146)
        at org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:334)
        at java.lang.Thread.run(Thread.java:479)
-- 
Darryl Stoflet
http://dstoflet.calweb.com