Sneha Raju
asked on
Need to retain the drop down value after submitting the form
I have a jsp page which contain drop downs and two buttons. One button for Upload and other is Run button. I want to retain the value of drop downs even after the Upload is clicked and submitted the form so that the same values should pass for Run button . I used the below code.
<select name="riskType" class="filter_smalltext" onchange="regAuthChange(); ">
<!-- <option value=0>Select...</option>
<option value="CR">CR</option>
<option value="MR">MR</option>
<option value="BOTH">Both</option> -->
<option value="" selected="selected">Choose One</option>
<option value="<%if(request.getPar ameter("ri skType").e quals("CR" )) {out.println('selected="se lected"'); } %>">CR</option>
<option value="<%if(request.getPar ameter("ri skType").e quals("MR" )) {out.println('selected="se lected"'); } %>">MR</option>
<option value="<%if(request.getPar ameter("ri skType").e quals("BOT H")) {out.println('selected="se lected"'); } %>">BOTH</option>
</select></td>
But i am getting this error :
jv_allocation_process.jsp: 16:18: Error in "jv_allocation_process.jsp " at line 401: Invalid character constant
<%@ include file="templates/jv_allocat ion_proces s.jsp" %>
^------------------------- ---------- ^
at weblogic.servlet.jsp.Javel inxJSPStub .reportCom pilationEr rorIfNecce ssary(Jave linxJSPStu b.java:247 )
at weblogic.servlet.jsp.Javel inxJSPStub .compilePa ge0(Javeli nxJSPStub. java:183)
at weblogic.servlet.jsp.Javel inxJSPStub .access$00 0(Javelinx JSPStub.ja va:50)
at weblogic.servlet.jsp.Javel inxJSPStub $1.run(Jav elinxJSPSt ub.java:11 1)
at java.security.AccessContro ller.doPri vileged(Na tive Method)
Truncated. see log file for complete stacktrace
>
<select name="riskType" class="filter_smalltext" onchange="regAuthChange();
<!-- <option value=0>Select...</option>
<option value="CR">CR</option>
<option value="MR">MR</option>
<option value="BOTH">Both</option>
<option value="" selected="selected">Choose
<option value="<%if(request.getPar
<option value="<%if(request.getPar
<option value="<%if(request.getPar
</select></td>
But i am getting this error :
jv_allocation_process.jsp:
<%@ include file="templates/jv_allocat
^-------------------------
at weblogic.servlet.jsp.Javel
at weblogic.servlet.jsp.Javel
at weblogic.servlet.jsp.Javel
at weblogic.servlet.jsp.Javel
at java.security.AccessContro
Truncated. see log file for complete stacktrace
>
Probably you have double quotes inside the string. Escape them first and then retry to run the code.
Just look close in what HTML you get with this:
You get wrong HTML with unclosed quote. You have to do:
<option value="<%if(request.getParameter("riskType").equals("CR")) {out.println('selected="selected"'); } %>">CR</option>
<option value="<%if(request.getParameter("riskType").equals("MR")) {out.println('selected="selected"'); } %>">MR</option>
<option value="<%if(request.getParameter("riskType").equals("BOTH")) {out.println('selected="selected"'); } %>">BOTH</option>
You get wrong HTML with unclosed quote. You have to do:
<option value="CR" <%if(request.getParameter("riskType").equals("CR")) {out.println('selected="selected"'); } %>">CR</option>
<option value="MR" <%if(request.getParameter("riskType").equals("MR")) {out.println('selected="selected"'); } %>">MR</option>
<option value="BOTH" <%if(request.getParameter("riskType").equals("BOTH")) {out.println('selected="selected"'); } %>">BOTH</option>
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.