Image will not appear for JSP page

Posted on 2009-04-19
Last Modified: 2012-05-06
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="*" %>

<%@ page import="java.sql.*" %>  

<%@ page import="javax.sql.*" %>

<%@ page import="java.util.*" %>    

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">



<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( {%>


				<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

Question by:surpriseV
    LVL 48

    Accepted Solution

    quick try, change:

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


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

    Author Closing Comment

    Ugh!  Thanks so much!  I really appreciate it.  My eyes are so strained after a week of coding and exams. You're the best!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Introduction This warning has to be one of the most commonly issued warnings in the history of PHP.  The article explains why this warning arises and what to do to mitigate the problem. How this Happens HTTP headers include many different kinds…
    Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
    In this tutorial viewers will learn how add a full-size background image to a webpage using CSS3. Create a new HTML document with an internal stylesheet.: In CSS, define the html element to have a background image. Use a high resolution image.: In t…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now