views:

29

answers:

1

I'm using Apache Tomcat 6.0.26 with java servlets and JSPs.

Whenever I'm trying to link to an external website, my anchor tags always contain my request context path before the external link. For example if my context path is http://localhost:8084/MyWebPage/ and I'm trying to link to www.google.com via this tag:

<a href="www.google.com">Google</a>

My anchor tag tries to go to http://localhost:8084/MyWebPage/www.google.com instead of www.google.com.

What am I missing here?

Thanks in advance.

+5  A: 

You're missing the scheme. Add it:

<a href="http://www.google.com"&gt;Google&lt;/a&gt;

It makes the link absolute. Right now you've a relative link which is relative to the current request URL and its behaviour is as per the specification.

BalusC