• 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:
  • Devaka Cooray
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
Bartenders:

Interesting statement in Servlet 3.0 specification (RequestDispatcher)

 
Bartender
Posts: 3961
43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All !

I was reading today Servlet 3.0 specification and noticed some confusing statement regarding RequestDispatcher in HttpSession chapter.

[7.3] Session Scope:


To illustrate this requirement with an example: if a servlet uses the
RequestDispatcher to call a servlet in another Web application,
any sessions
created for and visible to the servlet being called must be different from those visible
to the calling servlet.



I always assumed that RequestDispatcher can be used for forwarding only within the same web app. And if we need to redirect user's browser to another web app, we must use response.sendRedirect (but this is another story).

So, could someone comment on this? Is it really possible to forward to another web app using RequestDispatcher as stated in highlighted with red quote, or this is only hypothetical example? Maybe specification should be more clear in this section, and choose another example to demonstrate that session is not shared with other app contexts?

Best regards,
MZ
 
Sheriff
Posts: 9711
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well there is a getContext(String uri) method in the ServletContext class. You can call that method to get a ServletContext instance of another web application. Then on that ServletContext instance you can call getRequestDispatcher()...
 
Mikalai Zaikin
Bartender
Posts: 3961
43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howdy Ankit !

Thank you for the clarification. I see that it's possible 8-)

Thanks,
MZ

 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's possible but, because a lot of the details were left out of the spec, it's not very portable.
If you're going to go down that road, you need to really test things in the containers you plan to support as certain things will be different from container to container.

From reading your quote, it looks like 3.0 clarifies some of these things.

 
snakes are really good at eating slugs. And you wouldn't think it, but so are tiny ads:
The new gardening playing cards kickstarter is now live!
https://www.kickstarter.com/projects/paulwheaton/garden-cards
reply
    Bookmark Topic Watch Topic
  • New Topic