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 have tried to use a forward with RequestDispatcher but there is a problem.
My portlet is placed on a "page" on the portal site, so for example: http://www.example.com/example-page/ If I go to that URL my portlet is there
RequestDispatcher forwards to something like this: http://www.example.com/example-portlet-name/example-parameters/ "example-portlet-name" is what is specified in portlet.xml in my WEB-INF directory.
"example-parameters" is what would be specified with getRequestDispatcher.. like this:
Is it possible to redirect back to the "example-page" and still preserve the parameters? Does this make sense?
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,
posted 10 years ago
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.
incandescent light gives off an efficient form of heat. You must be THIS smart to ride this ride. Tiny ad:
Devious Experiments for a Truly Passive Greenhouse!