title: Servlets: forwarding to a resource in a different webapp
body: <p>I'm trying to construct a java web app along modular principles, with some common resources (JSPs, mainly) in one WAR, and some custom resources in another. This means JSPs scattered across different WARs.</p>
  
  <p>Now JavaEE frowns upon this sort of shenanigans, and wants you to put everything in one place. My current workaround to this is to have an Eclipse-triggered Ant script which copies the content of one WAR into the other, but this is not a pleasant solution (it's fragile and too IDE-dependent).</p>
  
  <p>Ideally, what I'd like to be able to do is for a servlet to forward to a JSP located in a different WAR to one in which it is itself deployed. This would allow greater freedom in how I assemble my WARs. However, the <code>RequestDispatcher</code> does not seem to support such things.</p>
  
  <p>Another possibility is to use <code>&lt;c:import&gt;</code>, which <em>does</em> allow resources to be imported from a different WAR (with some caveats). This would probably allow me to have a "hook" JSP in one WAR, which then drags in the required JSP from another. This is a bit clunky, though, and the fact that <code>&lt;c:import&gt;</code> permits it shows that the underlying servlet API does also. But how do I access that functionality via the <code>RequestDispatcher</code> in a servlet?</p>