aspose file tools*
The moose likes Portals and Portlets and the fly likes Redirect back to portlet from servlet keeping same parameters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Portals and Portlets
Bookmark "Redirect back to portlet from servlet keeping same parameters" Watch "Redirect back to portlet from servlet keeping same parameters" New topic
Author

Redirect back to portlet from servlet keeping same parameters

Kelly Chi
Greenhorn

Joined: Jan 14, 2010
Posts: 3
Hello,
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?

Thanks a lot, ~ K
Prasanna Sesh
Greenhorn

Joined: Jan 16, 2010
Posts: 2
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,


-Prasanna
Kelly Chi
Greenhorn

Joined: Jan 14, 2010
Posts: 3
Hello,

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.

Would you happen to have any ideas?

Thanks again
Kelly Chi
Greenhorn

Joined: Jan 14, 2010
Posts: 3
I just came across this post

http://www.liferay.com/community/forums/-/message_boards/message/4169638?_19_redirect=%2Fcommunity%2Fforums%2F-%2Fmessage_boards%2Fsearch%3F_19_redirect%3D%252Fcommunity%252Fforums%252F-%252Fmessage_boards%252Fstatistics%26_19_breadcrumbsCategoryId%3D0%26_19_breadcrumbsMessageId%3D0%26_19_searchCategoryId%3D0%26_19_threadId%3D0%26_19_keywords%3Dupload%2Bfile#_19_message_4170806

i'm going to start trying out this approach
Prasanna Sesh
Greenhorn

Joined: Jan 16, 2010
Posts: 2
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.
 
wood burning stoves
 
subject: Redirect back to portlet from servlet keeping same parameters