wood burning stoves*
The moose likes Servlets and the fly likes Setting image path Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Setting image path" Watch "Setting image path" New topic
Author

Setting image path

Sumukh Deshpande
Ranch Hand

Joined: Feb 17, 2008
Posts: 87

Hello,

I am trying to access an image stored in Tomacat's WebApp folder in a servlet.

Folder Hierarchy on WindowsXP machine is as Follows:
C:\ProgramFiles\TomcatInstallationDirectory \WebApp\MyWebApp\Winter.jpeg.

Now my question is what path should I specify in the servlet to access the image?

The URL will be http://localhost:8080/MyWebApp/MyServlet

Thanks in advance.





William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12781
    
    5
Now my question is what path should I specify in the servlet to access the image?


Specify in the servlet for access how?

If you want the servlet to open the image file using java.io.File and related methods - that works by operating system absolute paths .
If you want the servlet to write a HTML page with an IMG tag to fetch the image the url will have to be relative to the web application.

Bill
Sumukh Deshpande
Ranch Hand

Joined: Feb 17, 2008
Posts: 87

Specify in the servlet for access how?


I want to do :
[code]
PrintWriter pw;
pw = response.getWriter();
pw.println("
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Setting image path