JasperException: Attribute value request.getParameter is quoted with ” which must be escaped when used within the value

My JSP Code

 

<jsp:useBean id=”person1″ type=”com.saravanan.domain.Person”
  class=”com.saravanan.domain.Employee” >
 <jsp:setProperty name=”person1″ property=”empID” value=”<%= request.getParameter(“userID”) %>“/>
 <jsp:setProperty name=”person1″ property=”name” value=”<%= request.getParameter(“userName”) %>“/>
</jsp:useBean>

 

got below error

 

org.apache.jasper.JasperException: /TestBean.jsp (line: 12, column: 60) Attribute value  request.getParameter(“userID”)  is quoted with ” which must be escaped when

used within the value
 org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:42)
 org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:408)
 org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:89)
 org.apache.jasper.compiler.Parser.parseAttributeValue(Parser.java:280)
 org.apache.jasper.compiler.Parser.parseAttribute(Parser.java:229)
 org.apache.jasper.compiler.Parser.parseAttributes(Parser.java:162)
 org.apache.jasper.compiler.Parser.parseAttributes(Parser.java:153)
 org.apache.jasper.compiler.Parser.parseSetProperty(Parser.java:913)
 org.apache.jasper.compiler.Parser.parseStandardAction(Parser.java:1134)
 org.apache.jasper.compiler.Parser.parseElements(Parser.java:1451)
 org.apache.jasper.compiler.Parser.parseBody(Parser.java:1664)
 org.apache.jasper.compiler.Parser.parseOptionalBody(Parser.java:1002)
 org.apache.jasper.compiler.Parser.parseUseBean(Parser.java:958)
 org.apache.jasper.compiler.Parser.parseStandardAction(Parser.java:1136)
 org.apache.jasper.compiler.Parser.parseElements(Parser.java:1451)
 org.apache.jasper.compiler.Parser.parse(Parser.java:138)
 org.apache.jasper.compiler.ParserController.doParse(ParserController.java:242)
 org.apache.jasper.compiler.ParserController.parse(ParserController.java:102)
 org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198)
 org.apache.jasper.compiler.Compiler.compile(Compiler.java:373)
 org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
 org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
 org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
 org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
 org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
 org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

 
Solution:
We should use single quotes on the value parameter
<jsp:useBean id=”person1″ type=”com.saravanan.domain.Person”
  class=”com.saravanan.domain.Employee” >
 <jsp:setProperty name=”person1″ property=”empID” value=<%= request.getParameter(“userID”) %>/>
 <jsp:setProperty name=”person1″ property=”name” value=<%= request.getParameter(“userName”) %>/>
</jsp:useBean>

Advertisements

One Comment

  1. Posted May 30, 2013 at 5:01 pm | Permalink | Reply

    I think this is one of the most significant information
    for me. And i am glad reading your article. But should remark
    on few general things, The web site style is wonderful, the articles is really great : D.
    Good job, cheers

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: