title: Can I get an URLConnection for a file within a JAR within a non-exploded WAR?
body: <p>I have some resource files that are in the classpath of my web application (inside a JAR, if that matters). I know I can access the contents of those resources by calling e.g. <code>SomeClassLoader.getResourceAsStream( "/samples/myscript.txt" )</code>. I have tested this in the past in both <strong>exploded</strong> and <strong>non-exploded</strong> WAR files with success.</p>
  
  <p>However, to integrate with some other existing classes in my app, I need to provide an URLConnection object to that file. I tested and confirmed that calling <code>getResource("/samples/myscript.txt").openConnection()</code> works in <strong>exploded</strong> WARs (additionaly, debugging revealed that the result is a <code>file:///</code> URL to the exploded file).</p>
  
  <p>Question: will that method also work on <strong>non-exploded</strong> ("packaged?") WARs?</p>
  
  <p>(I currently do not have easy access to a server that deploys wars without exploding them, hence why I'm asking instead of outright trying it. Also, some servers (e.g. Jetty, Tomcat -- even with <code>unpackWARs="false"</code>) allows non-exploded deployments, but behind the scenes they unpack the war, effectively behaving like an exploded deployment -- and, evidently, working correctly. I think the servers that gave me trouble in the past were Websphere and Weblogic).</p>