tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Greg Trasuk" <stratus...@on.aibn.com>
Subject RE: Unable to use RequestDispatcher.forward() for HTML pages when in Tomcat 4
Date Thu, 21 Feb 2002 16:05:06 GMT
Hi:

	From Page 56 of the Servlet 2.3 spec:
<quote>
	The getRequestDispatcher method takes a String argument describing a
path within the scope of the ServletContext. This path must be relative to
the root
of the ServletContext and begin with a '/' The method uses the path to look
up a
servlet, wraps it with a RequestDispatcher object, and returns the resulting
object.
	<myemphasis>If no servlet can be resolved based on the given path, a
RequestDispatcher
is provided that returns the content for that path.
	</myemphasis>
</quote>

	That certainly seems to indicate that what you're trying should work.
Here's a couple ideas:
	1- Are you sure the path is right, considering your webapp context name?
If your webapp context was "/app", then the requestdispatcher for
"/html/authhome.html" would actually resolve to
"http://yourhost.com/app/html/authhome.html".  Is that what you're
expecting?

	2- Could you try renaming your html file to "authhome.jsp"?  Or is there a
specific reason that it needs to remain ".html".  A JSP file that contains
no scripting elements will behave exactly like an html file.  One possible
downside is that the file needs to be translated and compiled, which will
cause a slight delay to the first user that hits it, but I would think an
authorization page would be accessed pretty frequently, so it wouldn't be an
issue.

	3- Perhaps the response.sendRedirect(String URL) functionality would be
appropriate in your situation.  That would sidestep the whole issue by
simply letting the browser handle it.

Good luck.

Greg Trasuk, President
StratusCom Manufacturing Systems Inc. - We use information technology to
solve business problems on your plant floor.
http://stratuscom.ca

> -----Original Message-----
> From: Sriram Narayanan [mailto:sriramx_2000@yahoo.com]
> Sent: February 21, 2002 09:37
> To: Tomcat Users List
> Subject: Unable to use RequestDispatcher.forward() for HTML pages when
> in Tomcat 4
>
>
> Hello all,
>
> I am able to use the RequestDispatcher forward control from
> one JSP page to another. However I am unable to forward to HTML pages.
> From what I read in the Servlet API spec (there's an example
> for /garden/ etc) and the docs for RequestDispatcher(), one
> should indeed be
> able to forward to HTML pages....
>
> Here's what I have in my JSP:
>
> <%getServletContext().getRequestDispatcher("/html/authhome.htm
> l").forward(request,response);%>
>
> And here's what I found in the generated JSP page:
>
> --- beginepartial quote -----
>             application = pageContext.getServletContext();
>             config = pageContext.getServletConfig();
>             session = pageContext.getSession();
>             out = pageContext.getOut();
>
>             // begin [file="/notauthorized.jsp";from=(0,2);to=(0,92)]
>
> getServletContext().getRequestDispatcher("/html/authhome.html"
> ).forward(request,response);
>             // end
>             // HTML // begin
> [file="/notauthorized.jsp";from=(0,94);to=(1,0)]
>                 out.write("\r\n");
>
>             // end
>
> ----- end partial quote ----
>
> Could someone please point me to what it is that I'm doing wrong ?
>
> I have only the Servlet API spec with me, and not the JSP
> spec, which I have not been able to download yet (Internet
> connection problems)
>
> Thanks,
>
> Sriram
>
>
>
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
>
>
> --
> To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
> For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
> Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>
>


--
To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>


Mime
View raw message