• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Redirect back to portlet from servlet keeping same parameters

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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,
 
Kelly Chi
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Prasanna Sesh
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic