I just had a look at the docs for RequestDispatcher.forward()and here's a smal
part of what I read...
/**
 * Forwards a request from
 * a servlet to another resource (servlet, JSP file, or
 * HTML file) on the server. This method allows
 * one servlet to do preliminary processing of
 * a request and another resource to generate
 * the response.
....

Section 8.1 of the Servlet API spec 2.3 also has the following text
For example, in a context
rooted at�/�and a request to/garden/tools.html, a requestdispatcher obtained
viaServletRequest.getRequestDispatcher("header.html")will behaveexactly
like a call toServletContext.getRequestDispatcher("/garden/header.html").

So I do think that we can forward to html files, only I'm not able to get it
right.

I'm getting an IllegalStateException, which is supposed to be thrown in case
some context has already been written back to the browser.

I'm now having a look at the generated .java file to see if I can figure out
why such content is being written back.

SRiram
--- Zvika Markfeld <[EMAIL PROTECTED]> wrote:
> you cannot perform a dynamic forward to a static resource such as HTML file.
> try:
> * using a static include, if JSP ( <%@include file="myfile.html"%> )
> * performing a redirect ( response.sendRedirect("myfile.html") );
> btw I am not sure whether a relative url redirection will actually work. if
> not, try specifying the entire url starting from the http.
> zm.
>
>
> -----Original Message-----
> From: A mailing list for discussion about Sun Microsystem's Java Servlet API
> Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of Sriram N
> Sent: Wednesday, February 20, 2002 3:11 PM
> To: [EMAIL PROTECTED]
> Subject: RequestDispatcher.forward() works for jsps but not html files
>
>
> Hello,
>
> I am using Tomcat 4.0.1
> I have an html file in the root directory of my application, and am
> unsuccessful in trying to forward the request to this html file form within
> another jsp.
> E.g.
> The following code snippet gives me an IllegalStateException
> --- code snippet ---
> String forwardToURL = "/trial.html";
> ServletContext sc = getServletContext();
> sc.getRequestDispatcher(forwardToURL).forward(request,response);
> ---
>
> where as the following works just fine.
> --- code snippet ---
> String forwardToURL = "/trial.jsp";
> ServletContext sc = getServletContext();
> sc.getRequestDispatcher(forwardToURL).forward(request,response);
> ---
>
> Both trial.html and trial.jsp are in the root folder of my web application.
>
> Could someone offer some pointers on where I am going wrong ?
>
> Thanks,
>
> Sriram
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Sports - Coverage of the 2002 Olympic Games
> http://sports.yahoo.com
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>


__________________________________________________
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to