struts: problem getting images to show up

I am using struts with tiles.

all my images are in project/web/images/. in the html page I am using ./images/xyz.gif to refer to an image, this works fine was pages that are in web directory.

if my action forward path is /actions/customer then the image url becomes /actions/customer/images and hence is not able to find any of the images.

is there a easier way to deal with it. I am confused with paths.

Who is Participating?
evnafetsConnect With a Mentor Commented:
Couple of ways.

1 - use the struts html:img tag, which automatically adds in the servlet context part of the URL, and so will let you use absolute references
<html:img page="/images/xyz.gif">

2 - use the struts <html:base> tag on your page.
A base tag tells a web page where to resolve relative links to.
That means that you can use links relative to where your JSP is in the directory structure, rather than to the "action" you call it with.

muthiahmerchantAuthor Commented:
Thanks. <html:img>  worked very well.

along the same lines can you help me figure out how to determine the path for my right now I have to use an absolute path.

My app is in c:/myprojects/CAS but my tomcat is in C:\Program Files\netbeans-5.5beta\enterprise3\apache-tomcat-5.5.16

hence when i use user.dir it takes me to C:\Program Files\netbeans-5.5beta\enterprise3\apache-tomcat-5.5.16 and not c:/myprojects/CAS.

is there a way I can put my in c:/myprojects/cas/ and be able to use it without using absolut path.

I will award the points for this question. even if you don't  konw the answer to

Thanks a lot
muthiahmerchantAuthor Commented:
Sounds right. I will close this question

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.