aspose file tools*
The moose likes JSP and the fly likes passing images between the pages in Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "passing images between the pages in Servlet" Watch "passing images between the pages in Servlet" New topic
Author

passing images between the pages in Servlet

abhinas raj
Ranch Hand

Joined: Jun 02, 2012
Posts: 47
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
Bartender

Joined: Oct 14, 2005
Posts: 18660
    
    8

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

Joined: Jun 02, 2012
Posts: 47
i used already <%=lc%> as the value of src attribute but it not displaying the images.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18660
    
    8

Paul Clapham wrote:What HTML does it generate?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: passing images between the pages in Servlet