-
Dec 26th, 2010, 07:57 PM
#1
Problem in retrieving session data.
I am trying to store some Form values in Session and I like to retrieve them later on in subsequent JSP pages. I use SimpleFormController in my code. My problem is the onSubmit method in the controller is not getting executed.
This is how I store the Form values in the Controller inside OnSubmit method. Here selected_city and selected_city_value are Hash Maps that needs to be stored in the session.
protected ModelAndView onSubmit(HttpServletRequest request,
HttpServletResponse response, Object command) throws Exception {
.....
......
......
HttpSession sessionnew = request.getSession(true);
sessionnew.setAttribute("selected_city", selected_city);
sessionnew.setAttribute("selected_city_value", selected_city_value);
}
This is how I retrieve the session information from the session in the JSP Page.
HashMap<String, String> selected_city = (HashMap<String, String>) session.getAttribute("selected_city");
HashMap<String, Double> selected_city_value = (HashMap<String, Double>) session.getAttribute("selected_city_value");
String origin=selected_city.get("origin_city");
Can someone point me whether I am storing the session information in the correct way. If I remove the "HttpServletRequest request,
HttpServletResponse response," from the onSubmit method and other session information, I can see the onSubmit getting executed properly.
I am not able to understand why onSubmit method is not executed?
Note: I have zipped the project from Eclipse. Download this and import into Eclipse to reproduce the error.
http://rapidshare.com/files/43943209...Annotation.zip
Instructions to import the Project zip file.
a. Click on the “File”, select “Import”, select “General”, select “Existing Projects into Workspace”, select “Select the archive files”, select the Project zip file.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules