jQuery in Action, 2nd edition*
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 EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Including html generated by Servlet in jsp " Watch "Including html generated by Servlet in jsp " New topic
Author

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?

Thanks,
Sean
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4339
    
    2

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.


SCJP
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.
-Sean
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 agree. Here's the link: http://aspose.com/file-tools
 
subject: Including html generated by Servlet in jsp
 
Similar Threads
unable to view my translated JSP page
Resetting Values
session lost with window.open()
error HTTP Status 500 -
Java program to produce a HTML page