permaculture playing cards*
The moose likes Portals and Portlets and the fly likes processRequest(..) + render(..) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Portals and Portlets
Bookmark "processRequest(..) + render(..)" Watch "processRequest(..) + render(..)" New topic
Author

processRequest(..) + render(..)

K Riaz
Ranch Hand

Joined: Jan 08, 2005
Posts: 375
Hello,

What is the best way to dynamically inform the render methods about a different JSP page to use for a particular request? For example, depending on some logic in processRequest(), I might want to forward a user to "/test1.jsp" or "/test2.jsp". This is determined in processRequest(..), but the request dispatcher in the render methods need to know the destination. What would be the best way to inform it? The only (unelegant) solution I can think of is to set an attribute in the request with the destination in processRequest(), and then read it in render().

Can anyone think of a better way? I thought about using a private instance variable (set by processRequest, read by render), but this would probably have ramifications in a multi-threaded environment.

Regards.
Julien Viet
Greenhorn

Joined: Nov 08, 2005
Posts: 5
Indeed private instance variable would not work with the fact that a portlet is multithreaded.

Using a request attribute also will not work in some portlet containers (like JBoss Portal 2.2) because between the action and the render there is a request dispatching and the attribute is lost. Also this raises issues in a clustered environement on fail over.

The best way to do it is to set it as a render parameter in the action phase so the portlet can safely use it.


Julien Viet<br />JBoss Portal Project Lead
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: processRequest(..) + render(..)
 
Similar Threads
About doGet and doPost of Services
Communication with Servlets
soap serialization (newbie?)
Why does it die after init()?
passing object from one servlet to the other.