How to retrive the 'base url' : server url + project's name

hello

in my jsp I want to retrive the string that represent my context root like

http://localhost:8080/MyProject

I don't have found the specific method under the HttpServletRequest and others.

The only solution I have now is to concatenate the

request.getScheme(), request.getServerName(), request.getServerPort(),request.getContextPath()

there's a custom method that does this form me?

I ask that because I remember in the past I've found it

I have worked with Jboss and now I'm under Tomcat....

It was maybe a method of jboss container?

Thanks for your response

martina

[648 byte] By [martina69a] at [2007-11-26 13:08:33]
# 1
request.getRequestURL() http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/http/HttpServletRequest.html#getRequestURL()
tolmanka at 2007-7-7 17:20:03 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Hellothanks for your response. I've seen getRequestURL(), but with this I retrive all the request Url path.I need only the base path like http://localhost:8080/MyProjectMartina
martina69a at 2007-7-7 17:20:03 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
how about this stringString BaseUrl = request.getScheme()+"://"+request.getServerName()+":"+request.getContextPath();I'm encoding it as per w3 standards... as per i.e reasonable
RahulSharnaa at 2007-7-7 17:20:03 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
Use a regular expression to parse it.
tolmanka at 2007-7-7 17:20:03 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

Thanks for your response

I've just done something like that.. in particular I'm using that

new java.net.URL(request.getScheme(), request.getServerName(), request.getServerPort(),request.getContextPath())

it works ok

but I remember that in the past I've used one specific method to retrive all the base path. As I've just said.. I don't remember the method and I don't know if it depends that in the past I've used Jboss and today I'm using Tomcat

Maybe Jboss has a method that does this work .. I don't know

martina69a at 2007-7-7 17:20:03 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
regular expression? "too much work" for a simple scope I think
martina69a at 2007-7-7 17:20:03 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...