You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Guilhem SEMPERE <gu...@navasoft.net> on 2007/04/18 17:00:22 UTC

404 and originally requested URL

Hi

I am using Tomcat 5.5, having set it up so that any 404 error redirects 
to a 404.jsp I have written for custom handling.

Now I need access to the originally requested URL (the one which 
couldn't be found).  I couldn't find a way to do this.  All info I can 
get is that the requested URL is now 404.jsp, which I am not interested in.

Any help much appreciated.  Thanks in advance,

Guilhem


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: 404 and originally requested URL

Posted by Guilhem SEMPERE <gu...@navasoft.net>.
Yup, request.getAttribute("javax.servlet.forward.request_uri") does 
exactly what I need, thank you very much.



Rashmi Rubdi a écrit :
> Well, the wording in the servlet spec "The values of these attributes
> must be equal to the return values of the..." don't reflect what I
> see:
>
> I was thinking that request.getRequestURI returns the same results as
> request.getAttribute("javax.servlet.forward.request_uri")
>
> request.getRequestURI gives the URL of the 404 page but,
>
> request.getAttribute("javax.servlet.forward.request_uri") gives the
> URL of the invalid page that forwarded to the 404 page.
>
> Anyway, as you mentioned the OP should be able to get the forward URL
> from javax.servlet.forward.request_uri
>
> -Rashmi
>
> On 4/18/07, Hassan Schroeder <ha...@gmail.com> wrote:
>> On 4/18/07, Rashmi Rubdi <ra...@gmail.com> wrote:
>>
>> > > The Servlet Spec is your friend -- SRV 8.4.2, specifically :-)
>>
>> > No, none of the methods listed under SRV 8.4.2 show the referring URL
>> > information
>>
>> You misunderstand -- there is no reference to the "referrer" in the
>> original posting, nor is it relevant.
>>
>> The page being requested that was *not found* and hence caused
>> the /forward/ to the custom 404 page /is/ identified by the request
>> attributes mentioned in SRV 8.4.2 -- javax.servlet.forward.request_uri
>> and so on.
>>
>> -- 
>> Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: 404 and originally requested URL

Posted by Rashmi Rubdi <ra...@gmail.com>.
Ok, now I get it.

Sorry, it was my mistake for not reading the sentence carefully.

-Rashmi

On 4/18/07, Hassan Schroeder <ha...@gmail.com> wrote:
> On 4/18/07, Rashmi Rubdi <ra...@gmail.com> wrote:
> > Well, the wording in the servlet spec "The values of these attributes
> > must be equal to the return values of the..." don't reflect what I
> > see:
>
> > I was thinking that request.getRequestURI returns the same results as
> > request.getAttribute("javax.servlet.forward.request_uri")
>
> Read the entire sentence:
>
>  The values of these attributes must be equal to the return values
>  of the HttpServletRequest methods getRequestURI, getContextPath,
>  getServletPath, getPathInfo, getQueryString respectively, invoked on
>  the request object passed to *the first servlet object in the call chain*
>  that received the request from the client.
>
> The 404 page is *not* the "first servlet object" so obviously those
> values are not the same.
>
> HTH,
> --
> Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: 404 and originally requested URL

Posted by Hassan Schroeder <ha...@gmail.com>.
On 4/18/07, Rashmi Rubdi <ra...@gmail.com> wrote:
> Well, the wording in the servlet spec "The values of these attributes
> must be equal to the return values of the..." don't reflect what I
> see:

> I was thinking that request.getRequestURI returns the same results as
> request.getAttribute("javax.servlet.forward.request_uri")

Read the entire sentence:

 The values of these attributes must be equal to the return values
 of the HttpServletRequest methods getRequestURI, getContextPath,
 getServletPath, getPathInfo, getQueryString respectively, invoked on
 the request object passed to *the first servlet object in the call chain*
 that received the request from the client.

The 404 page is *not* the "first servlet object" so obviously those
values are not the same.

HTH,
-- 
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: 404 and originally requested URL

Posted by Rashmi Rubdi <ra...@gmail.com>.
Well, the wording in the servlet spec "The values of these attributes
must be equal to the return values of the..." don't reflect what I
see:

I was thinking that request.getRequestURI returns the same results as
request.getAttribute("javax.servlet.forward.request_uri")

request.getRequestURI gives the URL of the 404 page but,

request.getAttribute("javax.servlet.forward.request_uri") gives the
URL of the invalid page that forwarded to the 404 page.

Anyway, as you mentioned the OP should be able to get the forward URL
from javax.servlet.forward.request_uri

-Rashmi

On 4/18/07, Hassan Schroeder <ha...@gmail.com> wrote:
> On 4/18/07, Rashmi Rubdi <ra...@gmail.com> wrote:
>
> > > The Servlet Spec is your friend -- SRV 8.4.2, specifically :-)
>
> > No, none of the methods listed under SRV 8.4.2 show the referring URL
> > information
>
> You misunderstand -- there is no reference to the "referrer" in the
> original posting, nor is it relevant.
>
> The page being requested that was *not found* and hence caused
> the /forward/ to the custom 404 page /is/ identified by the request
> attributes mentioned in SRV 8.4.2 -- javax.servlet.forward.request_uri
> and so on.
>
> --
> Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: 404 and originally requested URL

Posted by Hassan Schroeder <ha...@gmail.com>.
On 4/18/07, Rashmi Rubdi <ra...@gmail.com> wrote:

> > The Servlet Spec is your friend -- SRV 8.4.2, specifically :-)

> No, none of the methods listed under SRV 8.4.2 show the referring URL
> information

You misunderstand -- there is no reference to the "referrer" in the
original posting, nor is it relevant.

The page being requested that was *not found* and hence caused
the /forward/ to the custom 404 page /is/ identified by the request
attributes mentioned in SRV 8.4.2 -- javax.servlet.forward.request_uri
and so on.

-- 
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: 404 and originally requested URL

Posted by Rashmi Rubdi <ra...@gmail.com>.
On 4/18/07, Hassan Schroeder <ha...@gmail.com> wrote:
> On 4/18/07, Guilhem SEMPERE <gu...@navasoft.net> wrote:
>
> > Now I need access to the originally requested URL (the one which
> > couldn't be found).  I couldn't find a way to do this.
>
> The Servlet Spec is your friend -- SRV 8.4.2, specifically :-)
>

No, none of the methods listed under SRV 8.4.2 show the referring URL
information, also
the Referer header is null.

Put these in 404.jsp

<%=request.getRequestURI()%><br/> Shows the URL of the 404 page and
not the page that sent it to the 404 page.

<%=request.getContextPath()%><br/>
<%=request.getServletPath()%><br/>
<%=request.getPathInfo()%><br/>
<%=request.getQueryString()%><br/>

The referer header is null
<%=request.getHeader("referer")%>

Hmm... there really doesn't seem to be a way to get the URL of the
page that caused the 404 error, inside the 404.jsp page --- probably
possible with a Filter.

Also AccessLogValve captures all URLs.


-Rashmi

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: 404 and originally requested URL

Posted by Hassan Schroeder <ha...@gmail.com>.
On 4/18/07, Guilhem SEMPERE <gu...@navasoft.net> wrote:

> Now I need access to the originally requested URL (the one which
> couldn't be found).  I couldn't find a way to do this.

The Servlet Spec is your friend -- SRV 8.4.2, specifically :-)

HTH,
-- 
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Jasper5 And Fedora Core 6, build-classpath problems

Posted by Mark Thomas <ma...@apache.org>.
When starting a new thread (ie sending a message to the list about a
new topic) please do not reply to an existing message and change the
subject line. To many of the list archiving services and mail clients
used by list subscribers this  makes your new message appear as part
of the old thread. This makes it harder for other users to find
relevant information when searching the lists.

This is known as thread hijacking and is behaviour that is frowned
upon on this list. Frequent offenders will be removed from the list.
It should also be noted that many list subscribers automatically
ignore any messages that hijack another thread.

The correct procedure is to create a new message with a new subject.
This will start a new thread.

Mark
tomcat-user-owner


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Jasper5 And Fedora Core 6, build-classpath problems

Posted by st...@bt.com.
I am trying to use Jasper on Fedora Core 6 to precompile some of my jsp
but I come across the following classpath builder errors when trying run
the jasper script:-

$ /usr/bin/jasper5.sh
/usr/bin/build-classpath: error: Could not find jasper-compiler Java
extension for this JVM
/usr/bin/build-classpath: error: Could not find jasper-runtime Java
extension for this JVM
/usr/bin/build-classpath: error: Could not find jsp-2.0-api Java
extension for this JVM
/usr/bin/build-classpath: error: Could not find servlet-2.4-api Java
extension for this JVM
/usr/bin/build-classpath: error: Some specified jars were not found
Usage: /usr/bin/jasper5.sh ( jspc )
Commands:
  jspc - Run the offline JSP compiler

I looked in the script to see what jar files the classpath builder
needed and compared that to similar looking jar files in /usr/share/java

By creating links to the following files I get rid of the errors

$ su -
# cd /usr/share/java
# ln -s jasper5-compiler.jar jasper-compiler.jar
# ln -s jasper5-runtime.jar jasper-runtime.jar
# ln -s tomcat5-jsp-2.0-api.jar jsp-2.0-api.jar
# ln -s tomcat5-servlet-2.4-api.jar servlet-2.4-api.jar
# exit
$ /usr/bin/jasper5.sh
Usage: /usr/bin/jasper5.sh ( jspc )
Commands:
  jspc - Run the offline JSP compiler

So what I am wondering is have I missed off installing a compatibility
package or is there a mistake in the jasper package that should either
create these links or change the names required in the script?

For reference the packages concerned are
tomcat5-servlet-2.4-api-5.5.17-6jpp.2
tomcat5-jsp-2.0-api-5.5.17-6jpp.2
tomcat5-jasper-5.5.17-6jpp.2

Steve Hindmarch
One IT - iBridge Development

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org