File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt in forwarding to Servlet/JSP in another Application

 
Senthil Kumar
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Tarun Yadav
Ranch Hand
Posts: 134
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for your reply
 
Senthil Kumar
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tarun Thanks a lot for your reply.
am clear now.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic