Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

<jsp:include> calling a servlet

 
Luis Centeno
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Ankit Garg
Sheriff
Posts: 9577
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Luis Centeno
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic