Hector Fabio Meza Martinez wrote:

> Hi.
> I'm writing a servlet that will take a parameter with the GET method. The
> parameter is supposed to be an url, and then the servlet should generate a
> html page with the link to the url
>
> The line of code used to do that is
>
> out.println("<P><FONT COLOR=/#8000FF/><A HREF=/"+url+"/>Link</A></FONT></P>");
>
> url is a string that was initialized with getParameter.
>
> The problem is that when the page is generated, the name of the server is
> appended to the link. I've tried this using servletrunner and vqserver. In
> example, if the url is www.yahoo.com the link points to
> localhost/www.yahoo.com. Apparently this is done by the server.
> Is there any way to avoid this, and to get the link pointing to the real URL?
>
> thanks
>
> Hector
>

By itself, "www.yahoo.com" is not a valid URL (although browsers let you cheat
when typing names into the Location field).  Try entering "http://www.yahoo.com"
as your query parameter and it should work fine.

What's going on is that the browser (not the server) sees a link not starting
with either "http://" or with "/", so it assumes that you are specifying a
pathname relative to the URL of the requesting page, instead of a host name of a
web site.

Craig McClanahan

___________________________________________________________________________
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