i am trying to deploy two web applications say appA and appB in same local host tomcat server and when the both the applications are up in running is it possible to call appB to appA using ajax call or redirect
Asked
Active
Viewed 1,833 times
2
-
Yes it is possible !!!! you need to get the context of appB in appA . – Neeraj Jain Mar 20 '15 at 06:15
-
Have you looked at HttpClient by Apache ? if they are servlet based (as you said web application), I think then you can use them to call get or post method. – Aman Gupta Mar 20 '15 at 06:16
-
can we do it seam frame work to respond to ajax call from another application with simple html or jsp page with out having any high level stuff – NagaRaj Mar 20 '15 at 06:48
2 Answers
1
What you are looking for toa chieve can be done using the following tomcat parameter:
(from docs)
crossContext
Set to true if you want calls within this application to ServletContext.getContext() to successfully return a request dispatcher for other web applications running on this virtual host. Set to false (the default) in security conscious environments, to make getContext() always return null.
example:
http://blog.imaginea.com/cross-context-communication-between-web-applications/
related discussions: What does the crossContext attribute do in Tomcat? Does it enable session sharing?
0
Try This Way
ServletContext ctx = request.getServletContext().getContext("/otherapp");
request.setAttribute("MESSAGE", "Hello There!");
RequestDispatcher dispatcher = ctx.getRequestDispatcher("/hello.jsp");
dispatcher.forward(request, response);
Note
To enable this feature in Tomcat we need to enable the
crossContext
attribute by setting the value totrue
, the default value isfalse
.

Community
- 1
- 1

Neeraj Jain
- 7,643
- 6
- 34
- 62