You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Luke Vanderfluit <lu...@chipcity.com.au> on 2007/05/10 07:44:01 UTC

get docbase / context root from within application

Hi. 

I have a jsp page and want to get hold of the absolute path to the context root /doc base directory.


I have my tomcat application deployed under /foo/bar/tomcat/webapps/ROOT/

This is the path I want to retrieve programmatically rather than hard code it.

Is there a way to do this?

Thanks.
Kind regards.
Luke Vanderfluit.
-- 
............._..
.|  .| |.|/.|_ .
.|__.|_|.|\.|_ .
:61 421 276 282:

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: get docbase / context root from within application

Posted by Luke Vanderfluit <lu...@chipcity.com.au>.
Hi.

10May2007 @ 15:14 Luke Vanderfluit thusly spake
> Hi. 
> 
> I have a jsp page and want to get hold of the absolute path to the context root /doc base directory.
> 
> 
> I have my tomcat application deployed under /foo/bar/tomcat/webapps/ROOT/
> 
> This is the path I want to retrieve programmatically rather than hard code it.
> 
> Is there a way to do this?

Always the same. The moment I post with a question I find the answer.
I should post sooner. But no. Err but yes. No definitely not. Yes I should. 

getServletContext().getRealPath("/")

Thanks Yoav Shapira...

doh!

Kind regards.
Luke.

> 
> Thanks.
> Kind regards.
> Luke Vanderfluit.
> -- 
> ............._..
> .|  .| |.|/.|_ .
> .|__.|_|.|\.|_ .
> :61 421 276 282:
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org

-- 
............._..
.|  .| |.|/.|_ .
.|__.|_|.|\.|_ .
:61 421 276 282:

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org