• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Setting image path

 
Ranch Hand
Posts: 87
IntelliJ IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.





 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
IntelliJ IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Specify in the servlet for access how?



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