This is taken right from the Tomcat Samples provided by Apache:
/**
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*/
import javax.servlet.*;
import javax.servlet.http.*;
public class servletToJsp extends HttpServlet {
public void doGet (HttpServletRequest request,
HttpServletResponse response) {
try {
// Set the attribute and Forward to hello.jsp
request.setAttribute ("servletName", "servletToJsp");
getServletConfig().getServletContext().getRequestDispatcher("/jsp/jsptoserv/
hello.jsp").forward(request, response);
} catch (Exception ex) {
ex.printStackTrace ();
}
}
}
-----------------------------------------------------------------
J a m e s B. S w a r t
Agere Systems - Colorado Design Centers
Unix/Windows Systems Administrator, WAN, LAN,
Desktop, Voice, Printers, Security Focal Point,
& Local CIO Service Delivery Manager Contact
VOICE: 720-494-2330 � FAX: 720-494-2331
-----Original Message-----
From: Hans Bergsten [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, December 05, 2001 5:36 PM
To: [EMAIL PROTECTED]
Subject: Re: hoe to add jsp tags in servlet
Ramesh Kesavanarayanan wrote:
>
> you can use
> PrintWriter out = res.getWriter();
> out.println(" <jsp forard />");
> out.flush();
> out.close();
No, I'm afraid that's not correct (even if you fix the spelling of
"<jsp:forward>"). The output written by a servlet to "out" is sent
to the browser, and the browser has no idea what to do with a
<jsp:forward> tag. Only a JSP container, that parses a JSP page,
knows how to handle this tag (and all other JSP tags).
If you want to forward from a servlet, look at the RequestDispatcher
class in the Servlet API.
Hans
--
Hans Bergsten [EMAIL PROTECTED]
Gefion Software http://www.gefionsoftware.com
Author of JavaServer Pages (O'Reilly), http://TheJSPBook.com
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://archives.java.sun.com/jsp-interest.html
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.jsp
http://www.jguru.com/faq/index.jsp
http://www.jspinsider.com
==========================================================================To
unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://archives.java.sun.com/jsp-interest.html
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.jsp
http://www.jguru.com/faq/index.jsp
http://www.jspinsider.com