File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes <jsp:include> calling a servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Professional Certification » Web Component Certification (SCWCD/OCPJWCD)
Reply Bookmark "<jsp:include> calling a servlet" Watch "<jsp:include> calling a servlet" New topic
Author

<jsp:include> calling a servlet

Luis Centeno
Ranch Hand

Joined: Jul 31, 2009
Posts: 46
I am testing include standard action and import custom tag capabilities calling a servlet. For such purposes I created below servlet

..and a JSP (importTables.jsp) which calls it using <jsp:include> and <c:import>

TagServlet class is mapped to /randomTag url-pattern in web.xml. When I try to access the JSP, I get the content of rndIntTable.jsp only once and <html> and <body> tags from importTables.jsp are not shown. I thought that <jsp:include> (as RequestDispatcher.include) would return the control to importTables.jsp and show randomTag servlet response twice...Does servlet commit response to the client when service method ends regardles how it was called?


SCJP 6 | SCWCD 5
Ankit Garg
Saloon Keeper

Joined: Aug 03, 2008
Posts: 9023

Luis, in TagServlet you are actually forwarding your request to rndIntTable.jsp, so the actual JSP page i.e. importTables.jsp cannot send any response of its own after that. Change the forward to include and then see what happens...


Javaranch SCJP FAQ | SCWCD Links
Luis Centeno
Ranch Hand

Joined: Jul 31, 2009
Posts: 46
Ankit,

You are absolutely right....it must have been include method from RequestDispatcher instead of forward. I changed it and it worked as expected, it brought the content of rndIntTable.jsp twice inside the html code...

Thanks
 
 
subject: <jsp:include> calling a servlet
 
developer file tools