Actually, what you might want to do is have all your servlets extend one
class, and have the include code there.  For example:

public abstract class MyBaseServlet extends HttpServlet
{
  public abstract void MyService(HttpServReq request, HttpServResp response)
{};

  public void service(HttpServReq request, HttpServResp response)
  {
    request.getRequestDispatcher("header.jsp").include(request, response);
    MyService(request, response);
    request.getRequestDispatcher("footer.jsp").include(request, response);
  }
}


Then, have all your servlets extend MyBaseServlet and implement MyService
instead of doPost or doGet.  For example:


public class HelloWorldServlet extends MyBaseServlet
{
  public void MyService(HttpServReq request, HttpServResp response)
  {
    response.getWriter().println("Hello world!");
  }
}


By using this method, it is much easier to maintain relationships between
your header/footer code.  For example, if you one day decide that you need
to introduce several sets of headers and footers, depending on user
preferences, you can make changes to just MyBaseServlet.

Hope that helps.

-jmc

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to