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

Call a Servlet on a different webbapp.

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

I am using response.sendRedirtect(), to call a servlet which is on another webapp. The problem here is that the URL is exposed to the end user.

I need to call Servlet2 from Servlet1. Servlet2 is on a different webapp.

I need to call Servlet2 by passing username and password in the URL, the values of which I will be using to authenticate and on authentication will populate the session.

I don't want the username/password values to be exposed to the user.

I tried using RequestDispatcher but the same gave problems while using the session created from the request. I could invoke the doGet() of Servlet2 and I could create, populate the session and could also generate a form.
On submission of the form which calls the doPost() of Servlet2, the session is found to be invalid.

I am not facing the above session invalid problem when I am using response.sendRedirect() while I call Servlet2 from Servlet1.

Please help me solve this problem.

Thanks,
Sreeni
[ May 17, 2006: Message edited by: sreeni san ]
 
Author
Posts: 836
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are your two Web applications deployed to the same container (i.e. in the same J2EE server instance on the same server)? If so, unless there are security restrictions preventing you from doing this, RequestDispatcher obtained for a foreign context should sort it for you.

In fact, if your applications are in the same container, using declarative container-managed security will give you access to single sign-on; all the credentials of the client will be maintained across all Web applications (so they actually only have to login once).
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In Tomcat, you would need to set the "privileged" attribute of the webapp declaration to "true" for this to work. By default it's false.
 
sreeni san
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have both of these servlet on tomcat and not on any J2EE server.

Thanks,
Sreeni
 
sreeni san
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply. Please let me know how do I set "privileged" attribute.

Thanks,
Sreeni
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Details on privileged web apps on Tomcat are here.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic