Retain the values in dropdown

I have a drop down of state list and needs to remeber the selected value once page reloaded. it is in JSP and Struts .
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

make hidden textfield then on page reload pass the value to the hidden textfield in that way you retain the value from the list.
Here's a sweet demo (by default the result is null until you select a value and submit) :

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    <h1>Retain Demo</h1><br>
    <form method="post" action="demo.jsp">
    <select name="List" class="style5" style="border:thin; background:#6AB5FF; color:#FFFFFF">
                      <option value="CheeseBurger" selected>CheeseBurger</option>
                      <option value="HamBurger">HamBurger</option>
                      <option value="DoubleCheeseBurger">DoubleCheeseBurger</option>
    <% String user1 = request.getParameter("List"); %>
    <br><br><input type="hidden" name="hdf1" value="<%=user1%>">
    Value of hidden field is : <% out.println("" + user1); %>
    <br><br><input type="submit" value="submit">
One other way is to keep the action form in session scope and it will then retain the last state [this will avoid any hidden field handling]
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

In struts-config.xml, for a particular action

          path="/pages/whateverPage.jsp" />

scope is defined to session here.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mgoutham22Author Commented:
I am sorry but that did not work for me . any other tips , i clicked on accept with out testing .

do u have a reset method in the actionForm? if yes, remove it. You need to restart the tomcat after the struts-config change. You can very well reopen the question.
mgoutham22Author Commented:
no reset method , i did restart weblogic after change.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.