Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

passing images between the pages in Servlet

 
abhinas raj
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am trying to develop an application on Shopping cart. in that i am getting problem , i am not able to display the image of the purchaged items in the Cart. I am not storing the image in database, i am using the location of image , here in this code <img src="<% out.println("\""+lc+"\""); %>" width="143" height="129" hspace="2" vspace="2" border="0"> . by using "<% out.println("\""+lc+"\""); %>" i tried to give the value to the
src attribute but its not working. in the "CART" attribute image location value is there. or if there is any other method please help me .......... thanks


<%
List list=(List)request.getAttribute("CART");
Iterator it=list.iterator();
while(it.hasNext()){

String lc=it.next().toString();
System.out.println("in showcart.jsp lc="+"\""+lc+"\"");

%>

<tr>
<td><%=lc %></td>

<td>
<form action= "removeFromCart.abhinas">
<input type="hidden" name="imagelocation" value="<%=lc %>"/>
<img src="<% out.println("\""+lc+"\""); %>" width="143" height="129" hspace="2" vspace="2" border="0">
<input type="submit" value="Remove From Cart"/>
</form>
</td>
 
Paul Clapham
Sheriff
Pie
Posts: 20750
30
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This line is pretty much a mess:



What HTML does it generate?

Hint: Look in the browser and do "View Page Source". If you then see that it isn't generating the right contents for that src attribute, then fix your scriptlet to generate the right contents.

I haven't used scriptlets for years because they are totally obsolete, so I don't know if I'm right any more, but if you are stuck with maintaining an old system from years and years ago, ask yourself why <%=lc%> isn't good enough in that position.
 
abhinas raj
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i used already <%=lc%> as the value of src attribute but it not displaying the images.
 
Paul Clapham
Sheriff
Pie
Posts: 20750
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:What HTML does it generate?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic