Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Problem regarding dropdown in JSP

gaurav_jainNov 1 2007 — edited Nov 1 2007
Hi,
I am using the following code in my JSP. Actually when i submit this jsp to a servlet then it sets the value of location attribute using request.setAttribute() and forwards it using RequestDispatcher and include.But when the JSP page reloads there is no effect of if-else.
<% if(request.getAttribute("location").equals("Chandigarh")){ %>
<select name="Location">
<Option value="Chandigarh" selected>Chandigarh</Option>
<Option value="Pune">Pune</Option>
</select>
<%}
else if(request.getAttribute("location").equals("Pune")){%>
<select name="Location">
<Option value="Pune" selected>Pune</Option>
<Option value="Chandigarh">Chandigarh</Option>
</select>
<% }
else{ %>
<select name="Location">
<Option value="Banglore" selected>Banglore</Option>
<Option value="Chandigarh">Chandigarh</Option>
</select>
<% } %>
I always see the code that is apecified in else block.
Please tell me the problem in this code.

Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 29 2007
Added on Nov 1 2007
15 comments
774 views