List of usage examples for javax.servlet ServletContext getRealPath
public String getRealPath(String path);
From source file:nl.strohalm.cyclos.themes.ThemeHelper.java
/** * Lists available themes// w ww.ja va2 s.co m */ public static List<Theme> listThemes(final ServletContext context) { final String path = context.getRealPath(THEMES_PATH); final File[] files = new File(path).listFiles(FILENAME_FILTER); final List<Theme> themes = new ArrayList<Theme>(files.length); for (final File file : files) { try { themes.add(read(file)); } catch (final ThemeException e) { // Skip this theme } } return themes; }
From source file:com.bedatadriven.renjin.appengine.AppEngineContextFactory.java
private static File contextRoot(ServletContext context) { return new File(context.getRealPath(context.getContextPath())); }
From source file:nl.strohalm.cyclos.utils.WebImageHelper.java
/** * Returns the new style image files//from ww w . ja va 2s . co m */ public static File[] newStyleImages(final ServletContext context) { final File dir = new File(context.getRealPath(NEW_STYLE_IMAGES_PATH)); return dir.listFiles(); }
From source file:nl.strohalm.cyclos.utils.WebImageHelper.java
/** * Returns the new system image files/* www. j av a 2 s.c om*/ */ public static File[] newSystemImages(final ServletContext context) { final File dir = new File(context.getRealPath(NEW_SYSTEM_IMAGES_PATH)); return dir.listFiles(); }
From source file:org.iterx.miru.support.servlet.dispatcher.context.BootstrapServletContextListener.java
private static String resolveContextPath(ServletContext servletContext) { String path;/* www . jav a 2 s . c o m*/ int next; path = ((URI.create(servletContext.getRealPath("/"))).getPath()).toLowerCase(); next = path.length() - 1; while (servletContext.getContext(path.substring(next)) != servletContext) { next = path.lastIndexOf('/', next - 1); } return path.substring(next); }
From source file:org.mobicents.servlet.sip.restcomm.Bootstrapper.java
public static void bootstrap(final ServletConfig config) throws BootstrapException { final ServletContext context = config.getServletContext(); final String path = context.getRealPath("WEB-INF/conf/vnxivr.xml"); LOGGER.info("loading configuration file located at " + path); // Initialize the configuration interpolator. final ConfigurationStringLookup strings = new ConfigurationStringLookup(); strings.addProperty("home", getRestCommPath(config)); strings.addProperty("uri", getRestCommUri(config)); ConfigurationInterpolator.registerGlobalLookup("vnxivr", strings); // Load the vnxivr configuration. XMLConfiguration configuration = null; try {//from w w w . ja va2 s . c om configuration = new XMLConfiguration(path); } catch (final ConfigurationException exception) { LOGGER.error("The VNXIVR environment could not be bootstrapped.", exception); throw new BootstrapException(exception); } // Register the services with the service locator. final ServiceLocator services = ServiceLocator.getInstance(); try { final Configuration runtimeConfiguration = configuration.subset("runtime-settings"); runtimeConfiguration.setProperty("home-directory", getRestCommPath(config)); runtimeConfiguration.setProperty("root-uri", getRestCommUri(config)); services.set(Configuration.class, runtimeConfiguration); final MgcpServerManager serverManager = getMgcpServerManager(configuration); services.set(MgcpServerManager.class, serverManager); final CallManager callManager = (CallManager) context .getAttribute("org.mobicents.servlet.sip.restcomm.callmanager.CallManager"); services.set(CallManager.class, callManager); services.set(ConferenceCenter.class, getConferenceCenter(serverManager)); services.set(SmsAggregator.class, getSmsAggregator(configuration)); } catch (final ObjectInstantiationException exception) { LOGGER.error("The VNXIVR environment could not be bootstrapped.", exception); throw new BootstrapException(exception); } }
From source file:nl.strohalm.cyclos.themes.ThemeHelper.java
/** * Returns the real file for the theme/*from www .j a v a 2s . com*/ */ public static File realFile(final ServletContext context, final String fileName) { final String path = context.getRealPath(THEMES_PATH); return new File(path, fileName); }
From source file:och.chat.web.ChatsAppProvider.java
private static ChatsApp createApp(ServletContext servletContext) throws IOException { Props props = directProps;//w w w .ja v a2s. co m if (props == null) { String webInfPath = servletContext.getRealPath("./WEB-INF"); String configPath = System.getProperty("och.chat.propsDir"); if (configPath == null) { configPath = webInfPath; } WriteProps startProps = createProps(configPath + "/chat.properties", webInfPath); if (System.getProperty("och.skipNetProps") != null) { props = startProps; } else { NetPropsClient netPropsClient = new NetPropsClient(startProps.getStrVal(netProps_chats_host), startProps.getIntVal(netProps_chats_port), startProps.getStrVal(netProps_chats_secureKey), startProps.getBoolVal(netPropsClient_waitConnect), startProps.getLongVal(netPropsClient_updateTime)); addUpdateSecureKeyListener(startProps, netPropsClient, netProps_chats_secureKey); Props netProps = netPropsClient.getProps(); props = new MultiProps(startProps, netProps); } } return ChatsApp.create(props, servletContext); }
From source file:ostepu.file.fileCache.java
/** * sichert eine Datei lokal (unter dem Hash ihrer URL) * * @param context der Kontext des Servlet * @param content der Inhalt der Datei/* w ww .j a v a 2 s.c o m*/ * @param URL der Pfad/URL der Datei, fr den Namen */ public static void cacheFile(ServletContext context, byte[] content, String URL) { String fileHash = DigestUtils.sha512Hex(URL); String localFile = context.getRealPath("/cache/" + fileHash); File folder = new File(context.getRealPath("/cache")); if (!folder.exists()) { // wenn der Ordner nicht existert, versuchen wir ihn anzulegen boolean succeeded = folder.mkdir(); if (!succeeded) { // wenn wir den Ordner nicht anlegen konnten, bringt das cachen nichts return; } } try { if (!Files.exists(Paths.get(localFile))) { OutputStream outputStream = new FileOutputStream(new File(localFile)); outputStream.write(content, 0, content.length); outputStream.close(); } } catch (IOException e) { // do something } }
From source file:ro.nextreports.server.web.themes.ThemesManager.java
public static String getTickImage(String theme, NextServerApplication application) { if (ThemesManager.RED_THEME.equals(theme)) { return "tick_red.png"; } else if (ThemesManager.BLUE_THEME.equals(theme)) { return "tick_blue.png"; } else if (ThemesManager.GREEN_THEME.equals(theme)) { return "tick_green.png"; }/*w ww . ja v a2 s . co m*/ String file = "tick_" + theme + ".png"; ServletContext context = application.getServletContext(); File imgFile = new File(context.getRealPath("images/" + file)); if (imgFile.exists()) { return file; } else { return "tick_green.png"; } }