Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Setting image path

 
Sumukh Deshpande
Ranch Hand
Posts: 87
Firefox Browser IntelliJ IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13074
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 87
Firefox Browser IntelliJ IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Specify in the servlet for access how?


I want to do :
[code]
PrintWriter pw;
pw = response.getWriter();
pw.println("
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic