We help IT Professionals succeed at work.

Using Paths Relative to Document Root in Tomcat/JSP

lukeinjax asked
Medium Priority
Last Modified: 2008-01-09
I am new to Tomcat/JSP and I have what I think is a fairly simple question, I just don't know enough to figure it out. I have a webapp with the following structure.


From index.jsp, if I want to reference my image1.jpg, it will work if I use src="images/image1.jpg", but src="/images/image1.jpg" doesn't. Same goes for stylesheets. I know that this must have something to do with what Tomcat considers the document root, but I can't figure out how to make it work.

Is there a way to use paths relative to the document root instead of relative to the current file? Maybe there's some configuration setting that I'm missing?
Watch Question

This question was just recently asked at
Use should use
src="<%= request.getContextPath() %>/images/image1.jpg",

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.