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.
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.