tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wyn Easton <wyn_eas...@yahoo.com>
Subject RE: Integrating servlet output into JSP
Date Sat, 18 Nov 2000 13:10:20 GMT
-- for carnell - I lost the message link

I had a moment to look at the Tomcat source and in
RequestDispatcherImpl saw that the service() method is called
for RequestDispatcher's forward() and include().
JSP's _jspService() is like a regular servlet's service() method.
So, if you want to include an already written Servlet that outputs HTML
in the doGet() method from a JSP you'll have to call the doGet() 
from the Servlet's service() method. 
You could also add a parameter to the path when creating the
RequestDispatcher that would allow you to
call the doGet() when you are including the Servlet from your JSP and
act as it did before if not included from your JSP. 
Like this:

--IN JSP--
RequestDispatcher rd =
 request.getRequestDispatcher("aServlet?JspInclude=true");
rd.include();

--IN aServlet service() method--
String jspIncld = (String)request.getParameter("JspInclude");
if (jspIncld != null)
if ( jspIncld.equals("true"))
{
  doGet(request,response);
  return;
}
... do normal servlet processing ...

=====
Wyn Easton
wyn_easton@yahoo.com

__________________________________________________
Do You Yahoo!?
Yahoo! Calendar - Get organized for the holidays!
http://calendar.yahoo.com/

Mime
View raw message