#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    13
    Rep Power
    0

    JSP directive from within a Servlet


    Hi All,

    sorry if this is stupidly simple, but I can't seem to figure it. Using Tomcat as a Stand-Alone server, I'd like to be able to write a JSP [include] directive from within my Servlet's [doGet] method and still have that executed as the servlet's page[stream] gets served up.

    But I'm not sure it's possible. At least I can't seem to get it to work.

    Tried writing both

    <%@ include file="header.jsp">
    <%@ include file="footer.html">

    and

    <jsp:include page="header.jsp">
    <jsp:include page="footer.html">

    But both just seem to come up as hidden text in the HTML source.

    Is it at all possible or am I barking up the wrong tree please?
  2. #2
  3. No Profile Picture
    Clueless llama
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Feb 2001
    Location
    Lincoln, NE. USA
    Posts
    2,353
    Rep Power
    117
    In a servlet you have to use this:
    Code:
    request.getRequestDispatcher("fileToInclude.jsp").include(request, response);
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    13
    Rep Power
    0
    That works like a charm.


    Thank you Nemi.

IMN logo majestic logo threadwatch logo seochat tools logo