tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Funk <>
Subject Re: lost output including a servlet in a JSP which includes a JSP
Date Tue, 06 Jul 2004 17:26:20 GMT
This is all wrong. You need to get a RequestDispatcher via:

<jsp:include> or <jsp:forward>

-- or --

RequestDispatcher rd = request.getRequestDispathcer(myPath);
rd.include(request, response);


M.Hockings wrote:
> What I want to do is to include a servlet in a .JSP.  For reasons that I 
> won't go into please assume that in the environment that I wish this to 
> run I cannot define a named servlet nor can I load by classname.
> A simplified version of what I have been doing is below:
> <%
> Class c = Class.forName("name-of-the-servlet-class");
> Servlet s = (Servlet) c.newInstance();
> s.init(this.getServletConfig());
> s.service(request, response);
> %>
> This sorta works.  That is, it will load and run the servlet and the 
> output from the servlet is deliverd to the browser.  But if the called 
> servlet class includes a .JSP then the output of that .JSP is never seen 
> though if debugged it does run OK and produces output.  The servlet 
> itself is generated by compiling a .JSP with jspc. What am I missing.
> I realize that this inquiry is not strictly Tomcat related but I figure 
> that the people who will have the knowledge answer to my lost output 
> mystery will be here!
> Your thoughts on this problem are appreciated.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message