This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
We are having two diferrent web application(Servlet/JSP based) on one application server. We want to integrate both application.
User will login through first application(say A). He will be provided with one menu option for calling another web application(say B). We want to know that how can we call the other servlet of another context from the application B's Servlet ?
Look at the HttpServlet.getServletContext(String) method.
One thing to keep in mind is that the servlet spec does not go into great detail about cross context communication so the behavior across different containers will be, at best, inconsistent. Security conscious containers disable this feature by default so you'll need to check with the documentation for your container and do some experimenting to see exactly how things will work.
See you can use response.sendRedirect(), however if you use that your request, response and session object will be deleted, and it will also visible to the end user that you are redirecting to another website. I have few thoughts which I like to share.
1. We can serialize the user object and send it across to another servlet which read (desterilize) this and created a session inn that 2 Server.
2. We can create a table which has to share by the 2 application and we can allow the user who has a valid session with respect to the both application. A new entry has to created when ever new user object was added and that entry has to be deleted when the user session expiries. Using Session listeners we can achieve this very easy... (Hope so)
Please share your thoughts if my assumption is wrong....
Joined: Dec 18, 2006
Assalam alekum Mohammed Yousuff,
Agreed with your suggestion.
Rigth now,we want to do the activity of app B via login through app A. Hence no need of session/request data of app A at present.
In case if require,we will see your points.
But one thing I want to ask, how to acheive the session management of users logged in,using Session listeners, which you are saying ver easy.
Thank you. Regards Baseet Ahmed
^^^ There is substitute for papers,but none for Trees. Save Trees. ^^^