title: How to make a download url for the jar file located under apache-tomcat WEB-INF/lib folder from remote server?
body: <p>Can anyone please tell me how to create a download link for a jar file which is located under <code>/WEB-INF/lib</code> folder of <code>apache-tomcat</code>. I am able to get the following jar file location as:</p>
  
  <pre><code>jar:file:/var/lib/tomcat7/webapps/cs/WEB-INF/lib/commons-fileupload-1.3.1.jar!/org/apache/commons/fileupload/disk/DiskFileItem.class
  </code></pre>
  
  <p>I want to build a download URL for this jar file so that I can download it from remote server to my local hard disk.</p>
  
  <p>I have following code for finding java-version:</p>
  
  <pre><code>public static Map&lt;String, String&gt; getJarVersions(ICS ics, ServletContext context)
    {
  
      ServletContextResource resource = new ServletContextResource(context, "/WEB-INF/lib/");
  
      File file = null;
      try
      {
        file = resource.getFile();
      }
      catch (IOException e)
      {
        log.error("Error reading /WEB-INF/lib/ directory. ", e);
        return new HashMap(0);
      }
      File[] jarFiles = file.listFiles();
      Map&lt;String, String&gt; jarNameVersion = new HashMap();
      File[] arr$ = jarFiles;int len$ = arr$.length;
      for (int i$ = 0; i$ &lt; len$;)
      {
        File jarFile = arr$[i$];
  
        JarFile jarfile = null;
        Manifest manifest = null;
        try
        {
          jarfile = new JarFile(jarFile);
          manifest = jarfile.getManifest();
          if (manifest != null)
          {
            Attributes attrs = manifest.getMainAttributes();
            String version = attrs.getValue("Implementation-Version");
            String vendor = attrs.getValue("Implementation-Vendor");
            if (vendor == null) {
              vendor = "Not applicable";
            }
            if (version == null) {
              version = "Not applicable";
            }
            version = version + " : " + vendor;
            jarNameVersion.put(jarFile.getName(), version);
          }
          else
          {
            jarNameVersion.put(jarFile.getName());
          }
          if (jarfile != null) {
            try
            {
              jarfile.close();
            }
            catch (IOException e)
            {
              log.error("Error thrown while closing the jar file ");
            }
          }
          i$++;
        }
        catch (IOException e)
        {
          log.error("Error reading JAR/MANIFEST file . ", e);
        }
        finally
        {
          if (jarfile != null) {
            try
            {
              jarfile.close();
            }
            catch (IOException e)
            {
              log.error("Error thrown while closing the jar file ");
            }
          }
        }
      }
      return jarNameVersion;
    }
  }
  </code></pre>