It's not a secret anymore!
The moose likes Servlets and the fly likes Different ContextRoot ..?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Different ContextRoot ..??" Watch "Different ContextRoot ..??" New topic

Different ContextRoot ..??

Karan V Praba
Ranch Hand

Joined: Oct 31, 2002
Posts: 41
Hi All,
I have to access the servlet in the other context root in different server(not in the same Server/Container).Is it possible..?
Please give me an idea to solve this issue.
Thnaks in advance.

Karan V Praba.
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

If it is running in the same cluster, you may still be able to use getServletContext().getContext("name of other context") to get a reference to the Servlet, but you may also need to enable this in security settings.... somewhere. (Sorry, I've done it, but I'm drawing a blank)
I'm not sure it's ever worth the effort though, and it's easier to just include the servlet code in your application.
[ December 15, 2003: Message edited by: David O'Meara ]
Mani Narain

Joined: Dec 14, 2003
Posts: 4
If you want to access a servlet which is in a different sever,u could use sendRedirect() method...
Karan V Praba
Ranch Hand

Joined: Oct 31, 2002
Posts: 41
I don't want to use redirect method since all my response has to go from my first servlet.
I agree. Here's the link:
subject: Different ContextRoot ..??
It's not a secret anymore!