1

We currently have an appserver setup where EVERYTHING is off of one big context root, and we copy class files and restart app servers to deploy. Not ideal. I'm trying to set up an ant script to do the build and deploy using wdeploy, and everything works, except I need my servlet to forward to jsps outside of the context root of my war file deploy. So I figure if I can put a symlink in my war file, it can point to somewhere outside of my context root space.

This is the goal I'm trying to achieve, perhaps the symlink isn't the best idea. I just need a way to forward outside of my context root from a servlet.

stu
  • 8,461
  • 18
  • 74
  • 112

3 Answers3

0

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

For details see: Servlets: forwarding to a resource in a different webapp

Community
  • 1
  • 1
Kai Moritz
  • 611
  • 2
  • 7
  • 19
0

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

digitalsanctum
  • 3,261
  • 4
  • 29
  • 43
0

You can always to HttpServletResponse.sendRedirect to send the user anywhere, but if you want to use RequestDispatcher.forward or jsp:forward, it only works within the app's context root.

I don't think it's that bad to have all your code under one context root, assuming it's related to one application. Creating multiple WARs for different parts of the same application seems to increase your maintenance cost with little gain.

davetron5000
  • 24,123
  • 11
  • 70
  • 98