• Post Reply Bookmark Topic Watch Topic
  • New Topic

problem writing ImageServlet?  RSS feed

hasan khan
Ranch Hand
Posts: 223
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if some body have time then only read my question as i am explaining my problem in detail.

i have a 2 websites named

a) http://www.site1.com
b) http://www.site2.com

in my site1 i have some jsp pages, and jsp have <img> tag.

<img src="images/myimage1.jpg">
<img src="images/myimage2.gif">

but site1 dont have folder images but it is at site2

i dont want to change my <img> tags to
<img src="http://www.site2.com/images/myimage1.jpg">
or to something else because i don't want to show any one that the images are coming from some other website.

so i have a created servlet named ImageServlet and its configuration in web.xml is like this :

i have mapped ImageServlet to jpg and gif files because i dont want to change <img> tags which more than 100 times in jsp pages in site1

so every request to jpg or gif files goes to ImageServlet

if the browser request for the image

servlet takes the request.getServletPath() in this case it is : /images/myimage1.jpg
and make url connection to site2 in this case : http://www.site2.com/images/myimage1.jpg

the servlet opens InputStream read the content of the image and send it back to the client.

now the problem starts here

whenever i type the url in the browser

my servlets doGet() is called for infinite time and the browser does not get any response

the code of my servlet :-

in my server console i can only see lines printed till urlcon
please help what is the problem or mistake here.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!