Register now or log in to join your professional community.
JSPs run at the server, while JavaScript runs at the client - never the twain shall meet.
The JSP already knows the URL of the page it's generating - what else are you looking for?But might be this can help you:-
There are few things you have to do in order to make it to work.
A. You need a servlet to store the selected value of SELECT in session in the first place. If the SELECT list is static , just store the selectedIndex in the session.
B. On the same JSP where SELECT resides, you need put a server side code close to this
%
final HttpSession curSession = request.getSession( false );
final String selectedIndex = (String)curSession.getValue(selectedIndexKeyName);
%>
to pull the selectedIndex out of the session you put in the first place.
C. write onLoad method for JSP where SELECT resides
<body onLoad='initPage ()'>
where intiPage() is a JavaScript function that will set SELECT list selectedIndex to previous value.
document.frmCity.selCity.selectedIndex = %= selectedIndex %>