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

html:image - strange!

A Patel

Joined: Aug 19, 2005
Posts: 14
I am trying to implement multiple form actions using Image Buttons and to display my image buttons on my JSP page, this is what I have:

<html:image property="addButton" src="AddDatabase.gif" alt="add" />
<html:image property="gotologinButton" src="GoToLogin.gif" alt="gotologin" />

This works fine. However I do not want my image files in the same directory as my JSP pages. So I create an images folder, throw my images in that directory and change my code as below:

<html:image property="addButton" src="/images/AddDatabase.gif" alt="add" />
<html:image property="gotologinButton" src="/images/GoToLogin.gif" alt="gotologin" />

This doesn't work. I also tried using back-slashes to show image path but that doesn't work either. Is this normal? How can I implement this?

Any help much appreciated.
Marc Peabody
pie sneak

Joined: Feb 05, 2003
Posts: 4727

A relative url must be relative to the browser's Address bar location, which may not be the same as your server's folder structure.

A good workman is known by his tools.
A Patel

Joined: Aug 19, 2005
Posts: 14
I figured it out. Instead of using src like in regular HTML, you use the page attribute to access relative images. Thanks to Aaron Johnson. He explains details in this article:
I agree. Here's the link:
subject: html:image - strange!
It's not a secret anymore!