@Override public String getContentType() { return WebApplication.get().getServletContext().getMimeType(url); }
@Override public String getMimeType(String fileName) { String mimeType = getServletContext().getMimeType(fileName); return mimeType != null ? mimeType : super.getMimeType(fileName); }
@Override public String getContentType() { return WebApplication.get().getServletContext().getMimeType(url); }
@Override public String getMimeType(String fileName) { String mimeType = getServletContext().getMimeType(fileName); return mimeType != null ? mimeType : super.getMimeType(fileName); }
private Manifest getWebAppManifest() throws IOException { final ServletContext servletContext = WebApplication.get().getServletContext(); final InputStream manifestInputStream = servletContext.getResourceAsStream("/META-INF/MANIFEST.MF"); if (manifestInputStream != null) { return new Manifest(manifestInputStream); } final File manifestFile = new File(servletContext.getRealPath("/"), "META-INF/MANIFEST.MF"); if (manifestFile.exists()) { return new Manifest(new FileInputStream(manifestFile)); } return null; }
/** * Construct. */ public SimpleSynchronousFilePageStore() { this((File)((WebApplication)Application.get()).getServletContext().getAttribute( "javax.servlet.context.tempdir")); }
/** * Construct. */ public SimpleSynchronousFilePageStore() { this((File)((WebApplication)Application.get()).getServletContext().getAttribute( "javax.servlet.context.tempdir")); }
/** * Construct. */ public TestFilePageStore() { this((File)((WebApplication)Application.get()).getServletContext().getAttribute( "javax.servlet.context.tempdir")); }
/** * Construct. */ public TestFilePageStore() { this((File)((WebApplication)Application.get()).getServletContext().getAttribute( "javax.servlet.context.tempdir")); }
protected boolean isActive() { Pattern onlyLetters = Pattern.compile("[^a-zA-Z0-9]"); String contextPath = WebApplication.get().getServletContext().getContextPath(); if (!contextPath.endsWith("/")) { contextPath += "/"; } String url = onlyLetters.matcher(contextPath + getRequest().getUrl()).replaceAll(""); String thisUrl = onlyLetters.matcher(menuItemUrl).replaceAll(""); return url.endsWith(thisUrl); }
@Override public InputStream getInputStream() throws ResourceStreamNotFoundException { final ServletContext context = ((WebApplication)Application.get()).getServletContext(); in = context.getResourceAsStream(url); if (in == null) { throw new ResourceStreamNotFoundException("The requested resource was not found: " + url); } return in; } }
protected boolean isMetaInfResourcesSupported() { if (META_INF_RESOURCES_SUPPORTED == null) { int majorVersion = WebApplication.get().getServletContext().getMajorVersion(); META_INF_RESOURCES_SUPPORTED = majorVersion >= 3; } return META_INF_RESOURCES_SUPPORTED; }
protected boolean isMetaInfResourcesSupported() { if (META_INF_RESOURCES_SUPPORTED == null) { int majorVersion = WebApplication.get().getServletContext().getMajorVersion(); META_INF_RESOURCES_SUPPORTED = majorVersion >= 3; } return META_INF_RESOURCES_SUPPORTED; }
@Override public void onComponentTag(Component component, ComponentTag tag) { super.onComponentTag(component, tag); String path = WebApplication.get().getServletContext().getContextPath(); if (StringUtils.isBlank(path)) { path = "/"; } tag.put("href", path); } });
/** * Get temporary directory path for storing temporary files for e.g images. * * @return temporary directory path for storing temporary files for e.g images. */ public static String getTemporaryDirPath() { ServletContext servletContext = WebApplication.get().getServletContext(); return ((File)servletContext.getAttribute("javax.servlet.context.tempdir")).getPath() + File.separatorChar + Session.get().getId() + File.separatorChar; }
@Override public void onComponentTag(Component component, ComponentTag tag) { super.onComponentTag(component, tag); String path = WebApplication.get().getServletContext().getContextPath(); if (StringUtils.isBlank(path)) { path = "/"; } tag.put("href", path); } });
/** * Gets the name of the cookie where the session id is stored. * * @param application * The current we application holding the {@link javax.servlet.ServletContext}. * * @return The name set in {@link javax.servlet.SessionCookieConfig} or the default value 'JSESSIONID' if not set */ public String getSessionIdCookieName(WebApplication application) { String jsessionCookieName = application.getServletContext().getSessionCookieConfig().getName(); return jsessionCookieName == null ? DEFAULT_SESSIONID_COOKIE_NAME : jsessionCookieName; }
/** * Get temporary directory path for storing temporary files for e.g images. * * @return temporary directory path for storing temporary files for e.g images. */ public static String getTemporaryDirPath() { ServletContext servletContext = WebApplication.get().getServletContext(); return ((File)servletContext.getAttribute("javax.servlet.context.tempdir")).getPath() + File.separatorChar + Session.get().getId() + File.separatorChar; }
@Override public void onComponentTag(Component component, ComponentTag tag) { super.onComponentTag(component, tag); String path = WebApplication.get().getServletContext().getContextPath(); if (StringUtils.isBlank(path)) { path = "/"; } tag.put("href", path); } });
public InputStream getInputStream() throws ResourceStreamNotFoundException { final ServletContext context = ((WebApplication)RequestCycle.get().getApplication()).getServletContext(); in = context.getResourceAsStream(url); if (in == null) { throw new ResourceStreamNotFoundException("The requested resource was not found: " + url); } return in; } }