images in jsp
[nobr]hello, i can successfully get images for items using AWS however not all items
have images and so some can be null. if an item has no image in that case i want
to display another of my own image...the code is
*************
<td>
<img src="<%=smallImage.getURL()%>" border="0" alt="click to view large image" onclick=window.open("<%=largeImage.getURL()%>") />
</td>
<%
}catch (Exception e){
%>
<img src="noimg.gif" border="0">
<%
}
*********************
however when the program is executed the noimg.gif does not appear
can anyone c the problem pls help...
thanks
[/nobr]
# 2
Instead of catchting an exception , you could use an IF THEN statementTest if smallImage is null , if it is not null then show the image else show your noimage.
# 3
I would not use a direct url to the image but go through a servlet.
<img src="imageservlet?<%=smallImage.getPath()%>" border="0" alt="click to view large image" onclick=window.open("imageservlet?<%=largeImage.getPath()%>") />
Where getPath returns the path of the image file in the web application file structure. Then the imageServlet would look for the file given by getPath() to see if the file exists. If the file does not exist or the value returned by getPath is null, the imageServlet would return the default image. If it does exist it will return the image.
# 4
hello,
i used a if-then loop however whenever there is a null image it does not output anything so most of the results are not output and only does that do have pictures in.... here is the code:
***********************
Image largeImage = item.getLargeImage();
Image smallImage = item.getSmallImage();
if (smallImage.getURL() == null){
%>
<img src="noimg.gif" border="0" />
<%
}else{
%>
<img src="<%=smallImage.getURL()%>" border="0" alt="click to view large image" onclick=window.open("<%=largeImage.getURL()%>") />
<%
}
******************
can any one c what the problem is pls
atleast in the try catch block it used to output other book details without
images but in dis case it does not