David Mellado Mart�n wrote:
>
> Hi all.
> I have a problem, with request.getHeader(). I need to use this method in a
> page to get the page that requested it. I do it with HTTP_REFERER variable.
> I tried in JRun and it runs well, but it doesn�t with Tomcat 3.2 .
>
> I�ve tried several enviroment variables to see if it happens with them same
> that with HTTP_REFERER , and it always happens. I get the correct values
> with JRun , but I always get null with Tomcat 3.2 .
>
> Why this happens?
The getHeader() method returns the value of an HTTP request header, not
an environment variable. Based on your description, it sounds like JRun
is not spec compliant since there's no HTTP header named "HTTP_REFERER";
that's the name of an environment variable typically available to a CGI
script (as you also say).
The name of the HTTP header that corresponds to the "HTTP_REFERER"
variable is called "Referer". So try getHeader("Referer") instead.
Look at the Servlet API for other methods that returns values
corresponding to other CGI environment variables.
Also note that the "Referer" header is not always sent with a request,
so you need still need to deal with the case when getHeader("Referer")
returns null. Cases when the header is not sent is typically if the
user requests a URL from a list of bookmarks or clicks on a link inserted
in an email.
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://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets