0

Hi all,
I want some inputs from you on the following issue.

I have two drop downs on a jsp page.On the selection of the first drop down the page will get refreshed and the second combo box will be loaded regarding the selection of the first drop down.
Now, everything is going fine except when the page get refreshed after selecting the first combo box the selected option of the first combo box is lost and changed to the default selected option "Please select".
All I want to know is that how can I maintain session to retain the selected option of the first combo box after the page gets refreshed.

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by javaAddict
0

Hi Koushik,

Below code is to set the session

//This code goes in server side (servlet).

HttpSession session = request.getSession(true); //create a session object
 session.setAttribute("key", "value");

//This code goes in client side (jsp).

// this will return the value in session
 String value=(String) session.getAttribute("key");

After getting the session value set it to first combo box in onLoad intself

we can also use the ajax to solve ur problem.

Edited by peter_budo: Keep It Clear - Do wrap your programming code blocks within [code] ... [/code] tags

0

Hi Koushik,

Below code is to set the session

//This code goes in server side (servlet).

HttpSession session = request.getSession(true); //create a session object
 session.setAttribute("key", "value");

//This code goes in client side (jsp).

// this will return the value in session
 String value=(String) session.getAttribute("key");

After getting the session value set it to first combo box in onLoad intself

we can also use the ajax to solve ur problem.

That is not the right way to use session. You shouldn't be putting things in the session for a simple submit or refresh page.

koushikroy1989, I assume that you submit the value of the first drop down list and then you load values to the second. If so, when you "send" the data of the second drop down list you can also send the value of the first drop down list and have that value selected.

Post some code so we can see how you send the data and how you load the second drop down list.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.