tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Edmund Urbani <>
Subject Re: getRealPath() returns real path plus context path
Date Tue, 06 Sep 2005 08:09:52 GMT
Franz-Josef Herpers wrote:

> Hi,
> I've a problem when using ServletContext#getRealPath() with Tomcat 5.5.9.
> My web application resides under the name "tool" in the webapps 
> directory. When I call 
> servletContext.getRealPath(request.getContextPath() I get the real 
> path but always with the context path added at the end. That means a 
> path like C:\path\to\tomcat\webapps\tool\tool.
> Is there any explanation for this behaviour? Or am I doing something 
> wrong?
> Thanks for any hints in advance
> Regards
> Franz
the getRealPath method simply returns a path inside the webapp's 
directory. eg. you can do getRealPath("images/someimg.jpg") and get the 
actual filesystem path for that file, so you can access it using and do something with it. getRealPath("/") should give you 
the webapp directory itself.
note that you probably should not use this method, if you ever want to 
be able to run your webapp directly from a .war file.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message