Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Servlets and JSP

My requirement is that servlet calls jsp and then there are checkboxes in jsp .After user clicks on them the same servlet continues processing. I have a ervlet that sets some attributes and then displays a jsp with the questdispatcher include method. on the jsp there are some checkboxes and i need the user to check them and return these back to the servlet exactly after the
point where the jsp was called in the first place.
I am having a problem in going about this. The request object from the servlet will set attributes and with request dispatcher include(request,response) the jsp is displayed and now after checking boxes on jsp how do i pass all of them back to the servlet. if there is a submit button it will again post to the servlet right ? but i want control to return to exactly that point. Also, if i set with response.setParameter, there is no response.getParameter on the servlet side.
please help !!
[938 byte] By [Purnima] at [2007-11-11 7:35:53]
# 1 Re: Servlets and JSP
Hello Purnima,
1) First of all you should call the JSP at the very end of what you are doing in the servlet. When the user chooses what ever options are there, you should call the doGet method of the same servlet from the JSP and from the doGet method of the same servlet, you should enclose the code needed for processing after the user chooses the options in a private method which will be called from method doGet.
2) For the parameters, why dont you use an HttpSession object to pass parameters between Servlets and/or JSPs.
This is one way of doing it.I hope this helps you. If you dont, you must provide the code and explain what the code does.
Regards.
Hasnain.
Hasnain at 2007-11-11 22:37:49 >