Gehan,
First, the HttpUtils class has been deprecated in the servlet 2.3 API. Use
HttpServletRequest.getHeader("Referer") to get the URL of the referring
document.

-Richard

At 11:47 PM 5/15/2002 -0700, you wrote:
>  Ok I've looked through the servlet API, and the tutorial on
>servlets and I still can't find an answer to my question. I know
>how to use the readers to read a stream. What I can't find is
>how to get the url of the web page which called the servlet...
>Example...
>
>I have a page: www.whatever.com/test/index.html
>This page has a line of text and a button:
>
>Welcome to my servlet test page
>____________________
>|Click here to test|
>--------------------
>
>When I click test I want the servlet to read the web page and
>append my name to the end, therefore printing:
>
>Welcome to my servlet test page
>____________________
>|Click here to test|
>--------------------
>
>GEHAN GEHALE
>
>Now.... I curently have..
>
>InputStream     is;
>URLConnection   uc;
>String urlStr =
>javax.servlet.http.HttpUtils.getRequestURL(request).toString();
>
>URL userUrl = new URL(urlStr);
>uc = userUrl.openConnection();
>is = userUrl.openStream();
>BufferedReader in = new
>BufferedReader(new InputStreamReader(is));
>
>
>The problem is the line:
>javax.servlet.http.HttpUtils.getRequestURL(request).toString();
>
>returns:
>www.whatever.com/servlet/servletTest
>
>the correct path of the servlet, but I want it to return:
>www.whatever.com/test/index.html
>the path to the html page which called the servlet
>
>I've tried:
>getRequestURL()
>getContextPath()
>getPathInfo()
>getPathTranslated()
>getRequestURI()
>
>All of these return the url to the servlet, not the html page
>
>If anyone could advise me on how to get the path to the web page
>which called the servlet that would be very helpfull and
>apriciated.  I know I could hard code the url in but I want the
>script to be independent, which is the whole point of object
>orientation.. anyways...
>
>Thanks for putting up with a newbie,
>
>Gehan Gehale
>
>Ps. Before anyone tells me... I know that
>HttpUtils.getRequestURL(request).toString();
>has been depreciated. I tried
>String urlStr = request.getRequestURL().toString();
>but I keep getting an error getRequestURL not a valid method
>
>__________________________________________________
>Do You Yahoo!?
>LAUNCH - Your Yahoo! Music Experience
>http://launch.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

Reply via email to