Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Pulling content from outside a webserver  RSS feed

 
Anthony Smith
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a webapp, that can display webpages that a user uploads. They can only upload, .JPG, .HMTL, .HTM, and .GIF. Here is my problem. Because of testing and the and continously expanding my war file, I dont allow the uploaded content to be stored in the webapp, or even in the servlet engine container, but rather somewhere else on the server that is not web-accessable. Now this works currently, but when I upload a html or htm file I have to go through the code and find any references to an image and chnage the location of where the image should be from something like <img src="adog.jpg">
to <img src="ImageServlet?image=adog.jpg"> so that my ImageServlet gets the image and writes it out to the buffer. Buggy and weird I know, but I bascially want a system where I can upload files to a place on the server not webaccessable and not have to manipulate the html files in order to get the images to display...
 
Steve Chernyak
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is sort of half of an idea:
Map all of the urls for these files to your ImageServlet (*.gif, *.jpg, etc.). This way any time an image is requested the servlet just has to look at what the resource is and retrive it (it would have to be able to figure out that its an image or something else on its own though). The problem is that whenever a resource from your application (the one that was't uploaded) is requested the servlet will intercept those too.
I was wondering about how to do this my self, and would be very interested in hearing ideas that actually work
 
Chris Reeves
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you put apache in front of tomcat, you could use rewrite rules to take care of this.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!