Re: Application base URL



Andrew Thompson wrote:
zakmck73@xxxxxxxx wrote:
..

Now, how may I know what exactly is "http://some.host.net:port/myApp/";
from whitin a JSP or a servlet?


<http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletContext.html#getRealPath(java.lang.String)>


That would give you only the RealPath relative to the local file system. (On my local server, it would return "/opt/tomcat55/webapps/myApp/xxx" )

The original question cannot really be answered in a global context. For instance, the same resource may be available under several variants of the URL. e.g. A certain page that may be accessible as "http://127.0.0.1:8080/myApp/index.jsp"; from my local machine would only be accessible with a different hostname/IP when the same is accessed from another machine on the internet.

This information therefore would be relevant only in the context of a particular HTTP request, and one can obtain it using :

request.getRequestURL();

BK

.