3 Replies Latest reply on Oct 21, 2003 2:12 AM by Jon Barnett

    Can't view images with context-root set to /

    just_a_w Newbie

      I am deploying a servlet on JBoss 3.2.1 using Jetty.

      I want people navigating to http://myhost to see my servlet.

      I have set the following:
      - in jboss-web.xml, set context-root to /
      - in web.xml, set url-pattern to /
      - port set to 80 (-Djetty.port=80)

      But when I set url-pattern to /, my images no longer display on the webpage. If I set the url-pattern to "something" and use , the images display....but I have to navigate to http://myhost/something.

      Within my .war file:
      images/blah.gif
      WEB-INF/lib/log4j.jar
      WEB-INF/classes/myServlet.class
      WEB-INF/jboss-web.xml
      WEB-INF/web.xml

      Any idea what I need to do to get my images to display?

      thanks

        • 1. Re: Can't view images with context-root set to /
          Jon Barnett Master

          context-root shifts around the absolute position.

          web.xml url-patterns are generally relative references. So when your relative references work you can apply your context-root mapping - try not using jboss-web.xml until things are working for referencing images normally.

          So if your WAR is myApp.war, try checking your application and see if things work with http://myhost/myApp. Work with your web.xml until your application operates correctly. When that is done, apply your jboss-web.xml.

          • 2. Re: Can't view images with context-root set to /
            just_a_w Newbie

            Good call, jonlee. Taking out the context-root and setting the url-pattern to "/*" revealed that the images aren't working in that configuration either.

            But why not? Why isn't the path found?


            If I set the url-pattern to "/something" and navigate to http://myserver/something, I can view the images.

            • 3. Re: Can't view images with context-root set to /
              Jon Barnett Master

              Typically you only map and pattern match on specific dynamic components - servlets. So my web.xml for the WAR (in WEB-INF) is:


              <servlet-name>Verify</servlet-name>

              <servlet-class>com.amity.cardflex.servlet.Verify</servlet-class>






              <servlet-mapping>

              <servlet-name>Verify</servlet-name>

              <url-pattern>/verify</url-pattern>

              </servlet-mapping>


              I specifically take something that matches a request for verify and call the Verify servlet.

              This allows references to static content the relative path, images/myimage.jpg to be accessed. I don't have a specific map for it. In your case, I don't think you want a general "match any reference" spec in your web.xml. Taking it out will stop your request being diverted elsewhere.