1

Hy!

My site calling:

http://localhost:8080/WebTest/index.jsp?image=1.JPG

Code:

<img src=<% request.getParameter("image");%>  alt="1"/>

The problem is that no image is shown. The image is the right parth.

This is working:

<img src="1.JPG" width="3872" height="2592" alt="1"/>

Please help

user547995
  • 2,036
  • 8
  • 33
  • 62

2 Answers2

2

The <% %> won't print anything. Use <%= %> to print something.

<img src=<%= request.getParameter("image") %>  alt="1" />

It's safe to put quotes around the attribute value

<img src="<%= request.getParameter("image") %>" alt="1" /> 

But much better is to just use EL instead of the since a decade discouraged scriptlets:

<img src="${param.image}" alt="1" />
Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
1

It's better to use

<img src="${param.image}" />
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
developer
  • 9,116
  • 29
  • 91
  • 150