Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Still struggling with using images in JSP files

843838Aug 1 2005 — edited Aug 4 2005
OK, since I last asked about this, I have learned it doesn't matter whether I am using Tomcat or Sun's application server. I have also learned that my HTML is correct.

I am using Netbeans 4.1.

I created a new project (using the jakarta directory structure), and told the wizard to use the embedded Tomcat server.

I placed a jpeg file called IMG_0072.JPG in the same directory as the file index.jsp that was created by the project wizrd.

Since I am running Apache webserver anyway, I created a directory called images in htdocs used by Apache.

Here is my first version of the body of index.jsp:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>

<h1>JSP Page</h1>

<img src="http://localhost:80/images/IMG_0072.JPG" height="50%" width="50%">
</body>
</html>


Using this file, the page displays properly! I.e., I can see the expected image on the generated page.

Clearly, my tag "<img src="http://localhost:80/images/IMG_0072.JPG" height="50%" width="50%">" is correct! If I change this to either "<img src="/IMG_0072.JPG" height="50%" width="50%">" or "<img src="IMG_0072.JPG" height="50%" width="50%">", the image disappears, and the http monitor tells me there is a 404 not found error!

If the problem is not with my code, it must be related to web application configuration, and I must have missed something important. Can anyone tell me what, and where I can find details and something related to best practices?

Thanks,

Ted
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 1 2005
Added on Aug 1 2005
6 comments
895 views