• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to display images on local disk(outside of WebContent of WAR) in jsp?  RSS feed

 
will zhang
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a web application, I want to display images on local disk(outside of WebContent of WAR) in jsp. I couldn't put it in "WebContent/images/" because the images are portraits of users and they could be changed dynamically. If I put images in "WebContent/images/", I have to transfer the images back and forth every time when I update my WAR file.

Obviously, in jsp, something like
"<img src="/home/username/images/local/PRTR.jpg" />"
doesn't work.

Is it durable to store the images at somewhere else like "/home/username/images/local/" in the server's local disk?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Create a servlet (or use whatever back-end technology you're using) that writes the image contents (and mimetype/etc.) to the response.
 
will zhang
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:Create a servlet (or use whatever back-end technology you're using) that writes the image contents (and mimetype/etc.) to the response.


Thanks, Dave, because I'm new for servlet, could you please give me a simple example on how to do this? I tried to find on the web but couldn't find examples.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!