|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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
|
|||
|
|||
|
In a servlet you have to use this:
Code:
request.getRequestDispatcher("fileToInclude.jsp").include(request, response);
|
|
#3
|
|||
|
|||
|
That works like a charm.
Thank you Nemi. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Java Help > JSP directive from within a Servlet |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|