File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Call a Servlet from another app Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Call a Servlet from another app" Watch "Call a Servlet from another app" New topic
Author

Call a Servlet from another app

Timothy Sam
Ranch Hand

Joined: Sep 18, 2005
Posts: 746
Hi guys, this might most be possible. We have 2 applications that integrates seemlessly with each other. Now, we have a problem of destroying the session of both applications when the user logoff. Would it be possible for a Servlet to sendRedirect or forward to another servlet from another application?

App1(Logoff.do, destroy session) ----> App2(Logoff.do, destroy session) ----> App1(login.do)


I'm not using Struts, the .do is just a convention.... Thanks!


SCJP 1.5
http://devpinoy.org/blogs/lamia/ - http://everypesocounts.com/
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
Originally posted by Timothy Sam:
Hi guys, this might most be possible. We have 2 applications that integrates seemlessly with each other. Now, we have a problem of destroying the session of both applications when the user logoff. Would it be possible for a Servlet to sendRedirect or forward to another servlet from another application?

App1(Logoff.do, destroy session) ----> App2(Logoff.do, destroy session) ----> App1(login.do)


I'm not using Struts, the .do is just a convention.... Thanks!


You can sendRedirect() to resource which is not in your application but not forward().

But I think, through sendRedirect(), it's not possible to send sth with request...

May be you can have a central place (DB or XML or something) for communication between both the application. :roll:
[ November 22, 2006: Message edited by: rathi ji ]
Timothy Sam
Ranch Hand

Joined: Sep 18, 2005
Posts: 746
Thank you very much! It seems that I need to put the complete URL String which is

http://www.google.com

because www.google.com just won't work in sendRedirect. Thank you!
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
Originally posted by Timothy Sam:
Thank you very much! It seems that I need to put the complete URL String which is

http://www.google.com

because www.google.com just won't work in sendRedirect. Thank you!


Send redirect actually works from the client side.

Consider a situation where you log off from application 1 and then the first application after invalidating the session , sends a sendRedirect for the logoff of the second application.
Before the client opens the new fresh connection with the second web application , you close the browser. In that case your system goes to a inconsistent state.

forward jsp tag works for forwarding to other web applications also.Check how that works.


Rahul Bhattacharjee
LinkedIn - Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Call a Servlet from another app
 
Similar Threads
How to replicate sessions between two web applications on the same tomcat?
Session time out
Spring session timeout using IE6
JBoss in Action: different class loaders for each web application
Session Variable