title: Shared JSP files across wars, using forward in java servlet
body: <p>I have a web application with multiple WARS. These WARS all perform different functions but have many things in common : Css, Js, headers and footers, and certain jsps to output error messages and confirmations of transactions. For good maintainabilty I dont want to have any of these shared files in multiple locations, rather, one location so If I make an edit to one, it shows up in all. Just basic code management stuff, I don't think I really need to explian this to anyone here on SO. </p>
  
  <p>For Css and Js, I have a root War and I just absolutely address all of the <code>&lt;link&gt;</code> and <code>&lt;script&gt;</code> tags to it. For Headers and Footers (jsp fragments) I am using <code>&lt;c:import&gt;</code> and am grabing again from the root war.  The final problem I have is shared jsps.  </p>
  
  <p>I often forward to these jsps after a user tries to perfrom an action which results in a change to our database to confirm that the transaction was completed or in other situations where I want to give formatted messages to the user. A Servlet might look like this...</p>
  
  <pre><code>public class sampleServlet extends ExtendedHttpServlet{ //ExtendedHttpServlet used to add common function to all of our HttpServlets including the foward function I use below. 
       public void doPost(HttpServletRequest request, HttpServletResponse response){
  
          //Do some preperation stuff here, then...
  
          try{
  
              ModelJob.insertNewControlMJob(user, submit);  //ModelJob is my inteface to our 'Job' Table Model... 
              submit.setSeqId(ModelJob.getSeqId(user, submit));
              EmailFactory.SUBMIT_NEW_EMAIL.sendCMAdminEmail(user, submit, null);
              EmailFactory.SUBMIT_NEW_EMAIL.sendUserEmail(user, submit, null);
  
              req.setAttribute("color","Green");
              req.setAttribute("message"," Job Successfully Submited. Sequece id : " + submit.getSeqId());
              forward("/WEB-INF/TransactionResult.jsp", req, resp); 
              return;
  
          }catch(Exception e){
  
              req.setAttribute("color","Red");
              req.setAttribute("message","Teradata failure : " + e.getMessage());
              forward("/WEB-INF/TransactionResult.jsp", req, resp);
              e.printStackTrace();
              return;
  
          }
       }
  }
  </code></pre>
  
  <p>With this being the forward method I call above defined in the superclass <code>ExtendedHttpServlet</code> : </p>
  
  <pre><code>protected void forward(String destination, HttpServletRequest request, HttpServletResponse response) 
  throws ServletException, IOException 
  {
      RequestDispatcher dispatcher = request.getRequestDispatcher(destination.toString());
      dispatcher.forward(request, response);
  }
  </code></pre>
  
  <p>But with this I have to have a copy of the TransactionResult.jsp in all of my wars, and it makes maintenance a little bit of a pain. </p>
  
  <p>My question is -- Is there any way I could get my forward function to find jsps in other WARs to forward to. Or maybe could I include the jsp in my EAR and have the forward find the jsp files there. It is my understanding that jsps are just files and are compiled at runtime by special servlets, so I dont see why this wouldnt be possible?</p>
  
  <p>Thanks for any advice / insight / help....</p>
  
  <p>Edit Since some of you asked which server, I am currently on Websphere v 7.0</p>