RE: getRealPath() returns real path plus context path
servletContext.getRealPath() is real path to the context path + the argument ... So if you say servletContext.getRealPath(hithere) .. It will return C:\path\to\tomcat\webapps\tool\hithere Regards Guru -Original Message- From: Franz-Josef Herpers [mailto:[EMAIL PROTECTED] Sent: 05 September 2005 20:40 To: Tomcat Users List Subject: getRealPath() returns real path plus context path 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 -- Franz-Josef Herpers Puschkinallee 9A 12435 Berlin 030/53 21 33 02 0173/54 23 666 [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: getRealPath() returns real path plus context path
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 java.io.File 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. Edmund - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: getRealPath() returns real path plus context path
Hi, Edmund Urbani wrote: 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 java.io.File 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. I know about the problem with the war file. That's the reason why I until today never used this method and apparently never read the Javadocs Thanks for the helpful answer. Regards Franz - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]