• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Doubt in forwarding to Servlet/JSP in another Application

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
Can anyone say how can we forward to a servlet/JSP available in another application(Context).

Thanks in advance.
Regards
Senthil
 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By default, you can't; it would be a security loophole.

But you can set it up depending on your server; for Tomcat, you need to first set the attribute 'crossContext' equal to true for the webapp's <Context> element.

You can then get the other context with ServletContext.getContext("/otherWebApp"). On this, you can then use the usual getRequestDispatcher() and RequestDispatcher.forward() methods.
 
Senthil Kumar
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot for your reply
 
Senthil Kumar
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But i have a question.
Sometimes we just forward to homepage of another site
example:
response.sendRedirect("www.xx.com");

In this case we are trying to access JSP/HTML of another application which is a resource of another application.
Is that true.In this case i have not made any settings as you said before.
 
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
With redirects, you're actually asking the browser to make a brand new request to the other URL. There is no server side interaction between the two applications.
 
Tarun Yadav
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, I don't think this:



will work. You'll need to add the protocol information:



The first one will simply append "www.xx.com" to the current request path!
[ October 25, 2007: Message edited by: Tarun Yadav ]
 
Senthil Kumar
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh OK... i got it...
so it means that we can send a request to another resource available in another application only by 2 ways.
1.Context.getContext("/xx");
2.response.sendRedirect("http://www.xx.com");
Is that right?
 
Tarun Yadav
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's correct but keep in mind that with an include(), you're sending the original request object (via server side call)but with a redirect you're sending a new request (by sending the location to the browser and asking it to ask for that resource).
[ October 26, 2007: Message edited by: Tarun Yadav ]
 
Senthil Kumar
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Tarun Thanks a lot for your reply.
am clear now.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic