Is it possible to pass a servlet to jsp outside of its context root?

We currently have an appserver setup where EVERYTHING is detached from one big context root and we copy the class files and restart the application servers for deployment. Not ideal. I am trying to set up an ant script to build and deploy using wdeploy and everything works, except that I need my servlet to send jsps outside of the context root of my war file deployment. So I believe that if I can place a symbolic link in my war file, it can point to a location outside the root context space.

This is the goal I am trying to achieve, maybe symlink is not a good idea. I just need a way to redirect from my context root from the servlet.

+1


source to share


3 answers


I'm not sure if a symbolic link will work and I agree it's not a good idea. Try to create a virtual directory pointing where your jsps are located.



0


source


You can always HttpServletResponse.sendRedirect

send the user anywhere, but if you want to use RequestDispatcher.forward

or jsp:forward

, it only works in the root context of the application.



I don't think it would be a bad thing if all of your code was under the same context root, assuming it is associated with the same application. Creating multiple WARs for different parts of the same application appears to increase maintenance costs with little gain.

0


source


It is possible to forward resources outside of your webapp context if another webapp is running in the same servlet container.

See Servlets: Forwarding to a Resource in Another Web Folder for details

0


source







All Articles