...
> I have a java based web application deployed on Apache Tomcat.
>
[quoted text clipped - 6 lines]
> image from the server and not the local machine on which it is being
> run?
Uh-huh.. well, to fix that, simply... wait (checks sub.)
Sub: URGENT! ....
Oh.. (checks watch) apparently I'm too late.
Never mind.
;-)
[ Look into ServletContext.getRealPath() ]
Andrew T.
javadev - 05 Nov 2006 17:23 GMT
Thanks Andrew
How can I get a handle to the servletcontext object?
Swetha
> ...
> > I have a java based web application deployed on Apache Tomcat.
[quoted text clipped - 20 lines]
>
> Andrew T.
javadev - 05 Nov 2006 17:25 GMT
I figured I can use application.getRealPath coz application is of type
ServletContext.
Thanks
Swetha
> ...
> > I have a java based web application deployed on Apache Tomcat.
[quoted text clipped - 20 lines]
>
> Andrew T.
javadev - 05 Nov 2006 17:52 GMT
Ok, what happens now when I use application.getRealPath(absPath) where
absPath is a string that contains the absolute path of the file (say,
C:\somePic.jsp) is that the absolute path just gets appended to the
path of the application on the server so it ends up as "C:\Program
Files\Tomcat\webapps\myApp\C:\somePic.jpg which still does not work.
Any ideas on what I can do to fix this?
> ...
> > I have a java based web application deployed on Apache Tomcat.
[quoted text clipped - 20 lines]
>
> Andrew T.
Daniel Pitts - 05 Nov 2006 22:40 GMT
> Ok, what happens now when I use application.getRealPath(absPath) where
> absPath is a string that contains the absolute path of the file (say,
> C:\somePic.jsp) is that the absolute path just gets appended to the
> path of the application on the server so it ends up as "C:\Program
> Files\Tomcat\webapps\myApp\C:\somePic.jpg which still does not work.
> Any ideas on what I can do to fix this?
Please don't top post, thanks.
Generally its a bad idea to serve files outside of some predefined
docroot. If you server C:\somePic.jpg, what is to prevent someone from
retrieving anything else on your hard drive? Its best to move the jpg
files into some resource directory under your webapp root.
Good luck,
Daniel.