| Author |
Is it possible to include a file from a Servlet ?
|
Francesco Marchioni
author
Ranch Hand
Joined: Sep 22, 2003
Posts: 175
|
|
Hi all, I'm using Tomcat 5.0.16 to develop my servlets. I can see that including pages from servlets is not done in the same page but rather is forwarded in another page. The code is quite simple: <i> public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); getServletContext(). getRequestDispatcher("/snoop.jsp"). include(request,response); } </i> This servlet displays the page "snoop.jsp" in another page, but I'd like just to have at the bottom of the page. Is it possible to do it? Thanks a lot Francesco
|
JBoss AS 5 Development
JBoss Tutorials
|
 |
Ali Gohar
Ranch Hand
Joined: Mar 18, 2004
Posts: 572
|
|
|
By default the included page is displayed at the bottom of the page where you included it.Post the full code of servlet.
|
 |
Francesco Marchioni
author
Ranch Hand
Joined: Sep 22, 2003
Posts: 175
|
|
Hello, thanks for your answer. Well, full code of the Servlet is just in those few lines in the doGet() method. Nothing else. Now if I think over it, it should be allowed to include a web page from a Servlet in the same web page, as the response has been already committed. (But so why they added the method "include" in a Servlet ?)Anyway I tested this on Tomcat 5.0.16. I'll try to have a run on another Application Server and see it. regards Francesco
|
 |
Ali Gohar
Ranch Hand
Joined: Mar 18, 2004
Posts: 572
|
|
I have included a jsp in a servlet its working fine. Its get included at the bottom of the page where i have included it. I have used tomcat. Its working fine.
|
 |
 |
|
|
subject: Is it possible to include a file from a Servlet ?
|
|
|