File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

servlets + images location

 
Andrew Mcmurray
Ranch Hand
Posts: 188
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Where is the best place to put images that you want your servlet to display? How would I refer to those images from my servlet? Is it just the relative path? Is this done differently then in JSPs?

Thanks.

jutah
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The images can go anywhere where the browser can reference them via URL. The same rules apply as with JSPs: the path should be server-relative (i.e. include the context path).

Remember that regardless of whether you are using a JSP, a servlet or whatever other server-side technology, the page is just a plain old HTML file by the time it gets to the browser.

This recent post may be helpful.
[ October 18, 2005: Message edited by: Bear Bibeault ]
 
Makarand Parab
Ranch Hand
Posts: 121
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
The best place to keep the images when developing a web application is
1. Create a images folder inside Web Content folder. Put all your images inside that folder.

In the servlet you can use the relative path to access the images
eg.. "../images/xyz.gif"

Regards
Makarand Parab.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I highly recommend against using relative paths. It creates artificial coupling between your files that makes the web app fragile and difficult to maintain or refactor.
[ October 18, 2005: Message edited by: Bear Bibeault ]
 
Mark Spritzler
ranger
Sheriff
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You know there was a character in "Point Break" called Johnnie Utah. By any chance are your parents big fans of that movie?

Mark
 
Andrew Mcmurray
Ranch Hand
Posts: 188
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the replies guys And yes I did get the name from point break.

Thanks,

jutah
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic