Two Laptop Bag
The moose likes Servlets and the fly likes Including html generated by Servlet in jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Including html generated by Servlet in jsp " Watch "Including html generated by Servlet in jsp " New topic

Including html generated by Servlet in jsp

Sean Casey
Ranch Hand

Joined: Dec 16, 2000
Posts: 625
I was reading Marty Hall's book on Servlets and Jsp and I thought that he mentioned that one could include the html generated by a servlet in a jsp page by using the <jsp:include> tag. I tried it but it generated an exception. Does anyone know if this can be done?

Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4351

i think i remember something about response.sendRedirect() where the servlet can provide part of the response then redirect to another servlet or a jsp to finish it. its been a while so im not sure.
Dont blindly believe everything I say.

Visit my download page
Sean Casey
Ranch Hand

Joined: Dec 16, 2000
Posts: 625
I'm specifically referring to the jsp:include tag. I know that you can use it to include other html pages, so I would think you would be able to use it to see the generated html of a servlet. Anyone else got any ideas?? Thanks for your help though, Randall.
Jeff Sunder
Ranch Hand

Joined: Jun 26, 2001
Posts: 47
I tried to do something similiar to this a whila back, but I got a IllegalStateException error every time. I think the problem is that the data must be transferred from the servlet to the jsp before the jsp's buffer is written. Something you might want to try is to put the html from the servlet into a variable and do the include as one of the first things in the JSP before the buffer is written. Let me know if this works or what solution you come up with, I am interested in how this would work.
[This message has been edited by Jeff Sunder (edited August 08, 2001).]
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Including html generated by Servlet in jsp
It's not a secret anymore!