File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Image is not displaying after Submit Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Image is not displaying after Submit" Watch "Image is not displaying after Submit" New topic

Image is not displaying after Submit

RaviSingh Kumar
Ranch Hand

Joined: Sep 04, 2007
Posts: 52

I am new to struts. I have include Header.jsp page in my all jsp page(ex Login.jsp). In header.jsp page i have used <img> tag to include a bitmap image.
When Login.jsp page is accessed for the first time , Image is displayed, but when i submit with invalid name and password, the same login page is shown with validation errors. But this time the image is not shown. Instead a cross mark is displayed.

Please let me know if am missing something. Thanks in advance.
Ankit Garg

Joined: Aug 03, 2008
Posts: 9462

Your Header.jsp must have a relative path to the image. So when the URL changes, the relative path stops working. Lets say the <img /> tag in your Header.jsp looks like this
<img src="images/header.jpg" />
Change it to
<img src="${pageContext.request.contextPath}/images/header.jpg" />

SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
I agree. Here's the link:
subject: Image is not displaying after Submit
It's not a secret anymore!