• 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 ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

processRequest(..) + render(..)

Ranch Hand
Posts: 375
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.

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