-2

How to display an image to jsp page ? It does not allow me to display . I am using simple servlet application and I have mention the correct path so path is not the issue .

Provide the solution as soon as possible.

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
Jaydeep
  • 1
  • 4
  • Please share your code and let us see what have you tried so far so that we can help to resolve the problem. – VPK Jan 30 '15 at 04:55
  • check your browser console for errors – singhakash Jan 30 '15 at 04:59
  • I am giving the path of image , not from database and it shows the the message which I have written in src attribute of img tag instead of showing image . I also tried in other browser that is IE but same issue occurs. – Jaydeep Jan 30 '15 at 05:43
  • Please share the suspicious portion of the code. "*it shows the the message which I have written in src attribute of img tag instead of showing image*". What do you mean by "*message*" in this context. The `src` attribute in `` is meant for a relative path. Try looking into the generated HTML code. You might be giving a wrong path in the `src` attribute in ``. – Tiny Jan 30 '15 at 06:03

2 Answers2

2

<img> tag in HTML or JSP, will trigger a GET request which the server has to handle.

EXAMPLE

if I have image like below

 <img src="images?imageName=xyz.png"/>

the browser will request the servlet on the server with the name images passing the parameter imageName and its value value.

the servlet images has to handle the request and send image information in the form of stream which gets back to the browser and be displayed on the page.

images is name given to a servlet

follow this thread for better understanding.

Community
  • 1
  • 1
saikumarm
  • 1,565
  • 1
  • 15
  • 30
0

Thank you for support . Problem is solved.

The problem was :

I was trying to fetch the image file dynamically and was writing the height attribute so it was concatinate my src with height so I removed height and wrote before src attribute .

It Works .....

Jaydeep
  • 1
  • 4