All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jboss.weld.environment.servlet.util.Servlets Maven / Gradle / Ivy

There is a newer version: 1.0.1-Final
Show newest version
package org.jboss.weld.environment.servlet.util;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;

import javax.servlet.ServletContext;

public class Servlets
{
   
   public static File getRealFile(ServletContext servletContext, String path) throws MalformedURLException
   {
      String realPath = servletContext.getRealPath(path);
      if (realPath==null) //WebLogic!
      {
         URL resourcePath = servletContext.getResource(path);
         if ((resourcePath != null) && (resourcePath.getProtocol().equals("file"))) 
         {
            realPath = resourcePath.getPath();
         }
      }
      
      if (realPath != null)
      {
         File file = new File(realPath);
         if (file.exists())
         {
            return file;
         }
      }
      return null;
   }
   
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy