I am still somewhat new to all this so please feel free to ask me to clarify if something I wrote doesn't make sense or isn't understandable.. I'll try to explain it the best I can..
In my portlet, I have a form in my view.jsp file that submits and passes parameters to a servlet.
I would like this servlet to redirect back to the original portlet while still maintaining the parameters.
I can't use sendRedirect because the objects don't transfer.
I assume that you are working with JSR 168 portlet. Instead of submitting directly to the servlet, submit to the same portlet as an action request. In the processAction, create a render URL to the portlet and set all the request parameters into it. You can then redirect to the servlet with this url as a query parameter using actionResponse.sendRedirect. The servlet can store this request parameter, do all the processing and forward or re-direct back to the url. Hope that helps,
Joined: Jan 14, 2010
Thank you very much for the reply.. I've gotten started on trying to do this one step at a time.. It seems like I might have to rethink other things too since this form also uploads a file into a database.
So I've changed my form so that instead of submitting to the servlet, it submits to the actionURL like this:
The problem is all the values passed through the form are now null. It appears to be because of enctype="multipart/form-data". If I take that part off, then my parameters go through. But the enctype="multipart/form-data" is necessary because I am uploading a file.
Multipart requests has to be handled correctly in order to read both the file contents as well as the parameters. The given link uses file upload components from apache to parse multipart requests. That should help resolve your problems.
subject: Redirect back to portlet from servlet keeping same parameters