while creating a login jsp page i m getting this error when the username and password is entered and clicked submitted...
org.apache.jasper.JasperException: /loginbean.jsp (line: 9, column: 57) 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: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)
Update 1
JSP Code used is
<jsp:useBean id="db" scope="request" class="logbean.LoginBean" >
<jsp:setProperty name="db" property="userName" value="%=request.getParameter("userName")%>"/>
<jsp:setProperty name="db" property="password" value="%=request.getParameter("password")%>"/>
</jsp:useBean>
You are missing a brace in your scriptlet tags:
Should be:
However, I would recommend against using scriptlets in general. You can bypass the use of setting properties like this, and can access the objects by using the implicit
param
object with JSTL. This of course depends on what the rest of your JSP is doing, but it's considered best practice.For example: