GAUTAM
asked on
String literal is not properly closed by a double-quote IN JSP
Hi experts...
I have an html tag embedded in a out.print statement and i've tried all permutations but am getting an error as String literal is not properly closed by a double-quote
This is my code:
out.println("<input type=\"hidden\" name=\"distVal\" value=<%=distVal%>>");
Please help...
I have an html tag embedded in a out.print statement and i've tried all permutations but am getting an error as String literal is not properly closed by a double-quote
This is my code:
out.println("<input type=\"hidden\" name=\"distVal\" value=<%=distVal%>>");
Please help...
Or.. you can try with the following correct one..
out.println("<input type=\"hidden\" name=\"distVal\" value=\"" + distVal + " \"/> ");
out.println("<input type=\"hidden\" name=\"distVal\" value=\"" + distVal + " \"/> ");
ASKER
Its still not working.
Actually i am trying to do a request.getParameter(distV al) in the next page after using
request.getRequestDispatch er("Edit.j sp").forwa rd(request , response);
Is this suppose to work.
Actually i am trying to do a request.getParameter(distV
request.getRequestDispatch
Is this suppose to work.
>>>>>>>>
out.println("<input type=\"hidden\" name=\"distVal\" value=<%=distVal%>>");
change this to
<input type="text" name="distVal" value="<%=distVal%>" />
out.println("<input type=\"hidden\" name=\"distVal\" value=<%=distVal%>>");
change this to
<input type="text" name="distVal" value="<%=distVal%>" />
Does the compilation error gone ?
Which page this line out.println("<input type=\"hidden\" name=\"distVal\" value=\"" + distVal + " \"/> ");
is in ?
Which page this line out.println("<input type=\"hidden\" name=\"distVal\" value=\"" + distVal + " \"/> ");
is in ?
if you are using request dispatcher forward..
then before dispatching you need to set the value, as attribute using following statement.
request.setAttribute("dist Val", distVal);
and in the jsp where you are doing request.getParameter, use request.getAttribute("dist Val").
That should do the trick.
then before dispatching you need to set the value, as attribute using following statement.
request.setAttribute("dist
and in the jsp where you are doing request.getParameter, use request.getAttribute("dist
That should do the trick.
ASKER
@cmalakar:out.println("<in put type=\"hidden\" name=\"distVal\" value=\"" + distVal + " \"/> "); is in a page known as check.jsp.Here i am setting this hidden type tag because if some error occurs in validation i have to repopulate the values in Edit.jsp which i am forwarding.
It's somehow not accepting this.
previously a page known as welcome.jsp also set this hidden tag in the same form with the same name.
Please help...
It's somehow not accepting this.
previously a page known as welcome.jsp also set this hidden tag in the same form with the same name.
Please help...
Set the value as attribute, as I said above
>>Actually i am trying to do a request.getParameter(distV al) in the next page after using
>>request.getRequestDispat cher("Edit .jsp").for ward(reque st, response);
Yes, if you forward the page, all the request parameters are forwarded as well.
I'm assuming that you're not having compile errors any more, and now you're saying that you don't get a value for the parameter "distVal"? If that's the case, then you're probably not setting a value. If a form variable doesn't have a value -- if distVal is empty, then it won't get sent to the server by the browser.
If you're still getting compile errors, then follow cmalakar's advise in the first post.
>>request.getRequestDispat
Yes, if you forward the page, all the request parameters are forwarded as well.
I'm assuming that you're not having compile errors any more, and now you're saying that you don't get a value for the parameter "distVal"? If that's the case, then you're probably not setting a value. If a form variable doesn't have a value -- if distVal is empty, then it won't get sent to the server by the browser.
If you're still getting compile errors, then follow cmalakar's advise in the first post.
ASKER
@cmalakar:I cannot use the setAttribute() because in one page i use request.getParameter() in one of the pages.So it causes a conflict.
@mrcoffee365:And i had a doubt that can we have parameteres set in request scope with the same name???
Please help...
@mrcoffee365:And i had a doubt that can we have parameteres set in request scope with the same name???
Please help...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<input type="hidden" name="distVal" value="<%=distVal%>" />