You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Arun Katkere <ka...@praja.com> on 2000/04/13 19:15:25 UTC

jsp:forward with URI's beginning with '/'

A JSP spec. question. How is the page attribute of jsp:forward action
interpreted when it starts with a '/'? Relative to the Web application root.
Or relative to the Web server root? If it is the former (TomCat 3.1 RC1
thinks so), then how do we forward wrt the Web server (to, say, a static
page not in any Web app, or a JSP/servlet in another Webapp)? Using absolute
URLs (ugh!)?

For example, in web application forwtest, I have two files:

test.jsp:
=========

<%@ page session="true" %>
<%
if(session.getValue("loggedIn") == null) {
  String dest = request.getRequestURI();
  dest = "login.jsp?dest=" + dest;
%>
<jsp:forward page="<%=dest%>"/>
<% } %>
This is test.jsp.

login.jsp:
==========

<%@ page session="true" %>
<% String dest = request.getParameter("dest");
 if(dest != null) {
   session.putValue("loggedIn", "true"); 
%>
<jsp:forward page="<%=dest%>"/>
<% } else { %>
"dest" is a required attribute.
<% } %>

When I access forwtest/test.jsp, I get the following error:

Error: 404
Location: /forwtest/forwtest/test.jsp
JSP file
"/usr/local/software/jakarta-tomcat/webapps/forwtest/forwtest/test.jsp" not
found 

When I access it again, it works, of course (since the login page dropped a
cookie before failing to forward to /forwtest/test.jsp).

If it is a TomCat bug (and not a spec. deficiency), let me know, and I will
file it as a bug. If someone has a workaround (using RequestDispatcher
directly, perhaps), let me know.

-arun



Re: jsp:forward with URI's beginning with '/'

Posted by Jeff Neuenschwander <je...@collegeguy.com>.
I have had a similar problem as well.  I think it is relative to the web
application root.  I wish it was set to the web server root though, because
I am trying to get it to forward to a cgi in my web server's cgi-bin
directory, which not under the application tree at all....

Jeff
----- Original Message -----
From: "Arun Katkere" <ka...@praja.com>
To: <to...@jakarta.apache.org>
Sent: Thursday, April 13, 2000 12:15 PM
Subject: jsp:forward with URI's beginning with '/'


> A JSP spec. question. How is the page attribute of jsp:forward action
> interpreted when it starts with a '/'? Relative to the Web application
root.
> Or relative to the Web server root? If it is the former (TomCat 3.1 RC1
> thinks so), then how do we forward wrt the Web server (to, say, a static
> page not in any Web app, or a JSP/servlet in another Webapp)? Using
absolute
> URLs (ugh!)?
>
> For example, in web application forwtest, I have two files:
>
> test.jsp:
> =========
>
> <%@ page session="true" %>
> <%
> if(session.getValue("loggedIn") == null) {
>   String dest = request.getRequestURI();
>   dest = "login.jsp?dest=" + dest;
> %>
> <jsp:forward page="<%=dest%>"/>
> <% } %>
> This is test.jsp.
>
> login.jsp:
> ==========
>
> <%@ page session="true" %>
> <% String dest = request.getParameter("dest");
>  if(dest != null) {
>    session.putValue("loggedIn", "true");
> %>
> <jsp:forward page="<%=dest%>"/>
> <% } else { %>
> "dest" is a required attribute.
> <% } %>
>
> When I access forwtest/test.jsp, I get the following error:
>
> Error: 404
> Location: /forwtest/forwtest/test.jsp
> JSP file
> "/usr/local/software/jakarta-tomcat/webapps/forwtest/forwtest/test.jsp"
not
> found
>
> When I access it again, it works, of course (since the login page dropped
a
> cookie before failing to forward to /forwtest/test.jsp).
>
> If it is a TomCat bug (and not a spec. deficiency), let me know, and I
will
> file it as a bug. If someone has a workaround (using RequestDispatcher
> directly, perhaps), let me know.
>
> -arun
>
>
>
> --------------------------------------------------------------------------
> To unsubscribe, email: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commmands, email: tomcat-user-help@jakarta.apache.org
>
>