Reputation: 28012
This is my jsp code:
<%@ page language="java" %>
<% String name = (String)request.getAttribute("name1"); %>
<html>
<head>
</head>
<body>
<%=name%>
<img src=<%=name%>></img>
</body>
</html>
When I come to the jsp page by writing the following code in my servlet:
request.getRequestDispatcher("test.jsp").forward(request, response);
I see that the path of the image is correctly displayed for
<%=name>
in the body portion, but the following < img > doesn't get executed and the image is not shown even though it exists in the displayed path.
Upvotes: 0
Views: 1387
Reputation: 21
put the scriptlet element in double quote("").
<img src="<%=name%>"></img>
Upvotes: 0
Reputation: 338
I think there might be some path issue. Try this.
<img src="<%=request.getContextPath()%>/images/<%=name%>"/>
Upvotes: 0
Reputation: 13057
I think it's a problem with the <
and >
inside of a HTML tag. Did you try JSP El?
<img src="${name}"/>
Upvotes: 2