Link to home
Start Free TrialLog in
Avatar of ragtan
ragtan

asked on

Reloading the jsp page

Hello,
    I have a problem in my code. Let me explain the scenario.
   I have a search button in a search.jsp page. when I click the search button I will be posting it to the controller /usr/search. When I come  back to the user search page. I need to display the search criteria entered by the user. there are 10 search criteria text boxes. with username. last name etc
  So how do I cache the search criteria?
To cache the criteria information
    I took the approach of setting up a session variables in another jsp page when the user clicks the search button. here is the code of the two pages
This is the another page where i'm setting the session variables
<%
   session.setAttribute("username_criteria", request.getParameter("usernames"));
   session.setAttribute("user_last_name_criteria", request.getParameter("user_last_names"));
   session.setAttribute("user_first_name_criteria", request.getParameter("user_first_names"));
   session.setAttribute("user_status_criteria", request.getParameter("user_status"));
   request.setAttribute("search_criteria_flag", "true");
%>  

Here is the javascript code where i'm submitting the pages

function searchUsers() {
       forward(document.userSearchForm,"/security/user/search_criteria.jsp","/user/user_search.jsp","/user/user_search.jsp");
               
forward(document.userSearchForm,"/security/usr/search","/user/user_search.jsp","/user/user_search.jsp");

}

forward is a javascript function which is used to submit a post to the pages which is passed as a parameters

the problem with this approach is sometimes it submits only the second one. sometime both the submits

How do I solve this problem.?Someone help me out solving this problem
Avatar of kokchoon78
kokchoon78

y u use java script to post your form ? u can post a form by action attribute in the html form tag, right ?

<form action="/user/user_search.jsp" method="POST">
...
...
</form>

Or, maybe u have your reason ?
ASKER CERTIFIED SOLUTION
Avatar of jarasa
jarasa
Flag of Spain image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial