File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Putting Application with in another Application ?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Putting Application with in another Application ??" Watch "Putting Application with in another Application ??" New topic

Putting Application with in another Application ??

Vijay Kashyap
Ranch Hand

Joined: Jul 30, 2001
Posts: 74
Hi All,
I am using Tomcat 4.01 as my WebServer. I am scratching my head if there is any way to add another application with in my current application so that I can work away without changing all the links in the added application.
Right now its pain in the neck to change all the links to avoid getting 404.
My current application structure is
jsp(main's jsps)
I want to add sub into this so it should look like
jsp (main's jsps)
In abc.jsp all my links refer to jsp's without any folder or application name. So the Tomcat tries to resolve it using the current application context like if I am using hyper-link def.jsp in abc.jsp, tomcat tries to find "http://myserver:8080/main/def.jsp" while I want it to look for "http://myserver:8080/main/sub/jsp/def.jsp".
The reason for doing this is to share the session information between these 2 different application. If they are put as 2 different application then I cannot share session information between them.
Could any body points out the easy and efficient way to achieve this, so that in future if I require to use sub as an independent application I have to make minimal changes.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17410

For servlets, this is easy - you do the servlet mapping in web.xml. Whether this mechanism works for JSPs as well, I don't know without reading the docs, but it's not un unreasonable thing to expect.

An IDE is no substitute for an Intelligent Developer.
Vijay Kashyap
Ranch Hand

Joined: Jul 30, 2001
Posts: 74
Thanks for replying.
I am wondering that if I rely on web.xml for servlet mappings what would be the impact if later on I have to move my application to IIS or say some other Web Server.
Another question
Is it possible to forward a request to some other application on the same server?
Rishi Singh
Ranch Hand

Joined: Dec 09, 2000
Posts: 321
you can share the session between two applications having two different servlet context all together.You need to use the HttpSessionActivationListener and call the sessionActivated/sessionPassivated once you migrate session.This should solve your problem of porting your application on a diffrent server.
whereas if don't want to do that and make it a part of the same context then u need to make the entry in the web.xml and set the document root accordingly
I agree. Here's the link:
subject: Putting Application with in another Application ??
jQuery in Action, 3rd edition