Using Paths Relative to Document Root in Tomcat/JSP

Posted on 2007-07-19
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?
Question by:lukeinjax
    1 Comment
    LVL 27

    Accepted Solution

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

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
    It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
    This video discusses moving either the default database or any database to a new volume.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now