• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 394
  • Last Modified:

Image will not appear for JSP page

Hi there,
I'm trying to create a simple JSP page that will display information in table form based on data in MySQL.  I've included the code below.  The retrievals work OK, but for some reason, the images are not appearing.  I'm using the WTP in Eclipse 3.4.1 and Tomcat 6 to test it on my machine.

Because of time constraints, I thought it would be best to put the name of the image file (audacity.jpg, for instance) in the database as opposed to the actual image or path.  The image folder is in my project workspace.  I've tried importing/including just that folder to no avail.  Thanks for any advice.  
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
<%@ page import="fancypaper.java.sources.*" %>
<%@ page import="java.sql.*" %>  
<%@ page import="javax.sql.*" %>
<%@ page import="java.util.*" %>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Fancy Paper Co.</title>
	<body bgcolor="Silver">
		<h1>Fancy Paper Co.</h1>
		DbAccess dbAccess = new DbAccess();
		Connection con;
		con = (Connection) DbAccess.getDBConnection();
		Statement st = con.createStatement();
		ResultSet rs = st.executeQuery("SELECT * FROM products");
		<table border="0">
			<%while(rs.next()) {%>
				<td><img src="images/"+<%= rs.getString(5)%>>
				<td><%= rs.getString(2) %></td>
				<td><%= rs.getString(3) %></td>
				<td><%= rs.getString(4) %></td>
			<%} %>

Open in new window

1 Solution
Ryan ChongCommented:
quick try, change:

<td><img src="images/"+<%= rs.getString(5)%>>


<td><img src="images/<%= rs.getString(5)%>"></td>
surpriseVAuthor Commented:
Ugh!  Thanks so much!  I really appreciate it.  My eyes are so strained after a week of coding and exams. You're the best!

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now