U
usenet-java
Hi all,
I have a web app deployed as a .war file. There are some images in the
root directory of the .war, and they're accessible just fine through
the browser, e.g.
http://localhost:8080/myApp/test.jpg
However, I'm running into a bit of trouble trying to load these images
from within the JSP code, in order to manipulate them. It works fine
with an absolute path to the file:
Image sourceImage =
Toolkit.getDefaultToolkit().getImage("c:\\myApp\\test.jpg");
...but this isn't portable, and I would much prefer to use relative
paths instead of hardcoding a particular filesystem location. After
Googling a bit, I've tried getting at the files a few different ways...
Image sourceImage = Toolkit.getDefaultToolkit().getImage("test.jpg");
Image sourceImage =
Toolkit.getDefaultToolkit().getImage(getClass().getResource("test.jpg"));
Image sourceImage =
Toolkit.getDefaultToolkit().getImage(request.getContextPath() +
"test.jpg");
No go on any of these. Could anyone please shed some light on the
proper way to load a file inside of the .war using a relative path?
Thanks!
I have a web app deployed as a .war file. There are some images in the
root directory of the .war, and they're accessible just fine through
the browser, e.g.
http://localhost:8080/myApp/test.jpg
However, I'm running into a bit of trouble trying to load these images
from within the JSP code, in order to manipulate them. It works fine
with an absolute path to the file:
Image sourceImage =
Toolkit.getDefaultToolkit().getImage("c:\\myApp\\test.jpg");
...but this isn't portable, and I would much prefer to use relative
paths instead of hardcoding a particular filesystem location. After
Googling a bit, I've tried getting at the files a few different ways...
Image sourceImage = Toolkit.getDefaultToolkit().getImage("test.jpg");
Image sourceImage =
Toolkit.getDefaultToolkit().getImage(getClass().getResource("test.jpg"));
Image sourceImage =
Toolkit.getDefaultToolkit().getImage(request.getContextPath() +
"test.jpg");
No go on any of these. Could anyone please shed some light on the
proper way to load a file inside of the .war using a relative path?
Thanks!