File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Context Path Still Won't Display an Image Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Context Path Still Won Watch "Context Path Still Won New topic

Context Path Still Won't Display an Image

Guy deLyonesse
Ranch Hand

Joined: Apr 12, 2011
Posts: 199

Hey all,

I don't do jsp pages often so I suspect my inexperience is the main cause of this one. I guess I get a little complacent in JSF land...

I'm trying to display a simple image in a jsp:

But all that displays is the alt text. The file is for sure in the /images folder, is spelled correctly and permissions on the file are read for everybody.

Seems like I'm missing something very simple.

I'm thinking maybe a web.xml problem, as if I try to enter the url of the image in my browser it redirects to the jsp page itself so the servlet is intercepting the request and matching it to a configured value. If so, I think this:

May be the issue due to the /* url pattern. I need to preserve this level of security, so does this mean I'll have to host the images in a separate webapp context?

Guy deLyonesse
Ranch Hand

Joined: Apr 12, 2011
Posts: 199

So 5 minutes after I posted that I realized the problem.

In the url-pattern I had been using a / only, instead of an actual string. Thus, the server was taking the separate URL request for the image and returning it as the same jsp page. By changing it to /welcome and adding /welcome to the request I got it to work.
Consider Paul's rocket mass heater.
subject: Context Path Still Won't Display an Image
Similar Threads
Problem with secure connection and Form Based Authentication
<user-data-constraint> working example
Security issue
scwcd study kit question???
Simple form-based authentication using JAAS