0 Replies Latest reply on Jul 8, 2004 1:40 PM by dmarshal01

    Tomcat/Jetty ServletContext.getResource() implementation dif

    dmarshal01

      I am trying to migrate my application to Tomcat from Jetty and am running into a snag with the way Jetty/Tomcat implement thier method getResource(). Why does Tomcat return a JNDI reference URL and Jetty returns a File reference URL? I am trying to read files that are located in my WAR under /folder directory. What code change can I make in order for this to work on both Jetty and Tomcat implementations?

      URL url = ServletContext.getResource( "/folder/file.txt");
      System.out.println( "url: " + url.toString() );

      Jetty Results:
      url: file:/home/jboss/server/default/deploy/myapp.ear/myapp.war/folder/file.txt

      Tomcat Results:
      url: jndi:/localhost/warcontext/folder/file.txt