/** * Get the servlet context for the servlet or filter, depending on * how this class is registered. * * @return the servlet context for the servlet or filter. */ @Override public ServletContext getServletContext() { if (filterConfig != null) { return filterConfig.getServletContext(); } return super.getServletContext(); }
/** * Get the servlet context for the servlet or filter, depending on * how this class is registered. * * @return the servlet context for the servlet or filter. */ @Override public ServletContext getServletContext() { if (filterConfig != null) { return filterConfig.getServletContext(); } return super.getServletContext(); }
protected void redirect(HttpServletRequest request, HttpServletResponse response, String pathInfo) throws ServletException { boolean customServletPath = dispatcherServletPath != null; String theServletPath = customServletPath ? dispatcherServletPath : "/"; ServletContext sc = super.getServletContext(); RequestDispatcher rd = dispatcherServletName != null ? sc.getNamedDispatcher(dispatcherServletName) : sc.getRequestDispatcher((theServletPath + pathInfo).replace("//", "/")); if (rd == null) { String errorMessage = "No RequestDispatcher can be created for path " + pathInfo; if (dispatcherServletName != null) { errorMessage += ", dispatcher name: " + dispatcherServletName; } throw new ServletException(errorMessage); } try { for (Map.Entry<String, String> entry : redirectAttributes.entrySet()) { request.setAttribute(entry.getKey(), entry.getValue()); } HttpServletRequest servletRequest = new HttpServletRequestRedirectFilter(request, pathInfo, theServletPath, customServletPath); if (PropertyUtils.isTrue(getServletConfig().getInitParameter(REDIRECT_WITH_INCLUDE_PARAMETER))) { rd.include(servletRequest, response); } else { rd.forward(servletRequest, response); } } catch (Throwable ex) { throw new ServletException("RequestDispatcher for path " + pathInfo + " has failed", ex); } }
InputStream is = servlet.getServletContext().getResourceAsStream( serializationPolicyFilePath); try {
assertNotNull(mockServlet.getServletContext()); assertEquals(contextName, mockServlet.getServletContext().getServletContextName()); assertEquals(Key.get(HttpServlet.class).toString(), mockServlet.getServletName());
/** * @return Wrapped version of the ServletContext initiated by {@link #init(javax.servlet.ServletConfig) } * @inheritDoc */ @Override public ServletContext getServletContext() { return disableSyncForward ? super.getServletContext() : contextAD; }
@Override public ServletContext getServletContext() { if (parent != this) return parent.getServletContext(); else return super.getServletContext(); }
@Override public ServletContext getServletContext() { return delegate.get().getServletContext(); }
@Override public ServletContext getServletContext() { return delegate.get().getServletContext(); }
public String getContextParameter(String name, HttpServlet servlet) { return servlet.getServletContext().getInitParameter(name); } public String getContextPath(HttpServlet servlet)
/** * store to session scope */ public void storeToContext() { ServletContext servletContext = GrouperUiFilter.retrieveHttpServlet().getServletContext(); if (servletContext.getAttribute("contextContainer") != instance) { servletContext.setAttribute("contextContainer", instance); } }
private HttpServletRequest createRequest(WebSocketRequestMessage message, WebSocketSessionContext context) { return new WebSocketServletRequest(context, message, servlet.getServletContext()); }
public static ConfigurationProperties getBean(HttpServlet servlet) { if (servlet == null) { throw new NullPointerException("servlet may not be null."); } return getBean(servlet.getServletContext()); }
private void dropWSSession(){ MessageContext messageContext = MessageContext.getCurrentContext(); HttpServlet servlet = (HttpServlet)messageContext.getProperty(HTTPConstants.MC_HTTP_SERVLET); ServletContext servletContext = (ServletContext)servlet.getServletContext(); HttpSession session =((HttpServletRequest)messageContext.getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST)).getSession(); session.invalidate();
public ServletContext getServletContext() { HttpServlet srv = (HttpServlet) getMessageContext().getProperty(HTTPConstants.MC_HTTP_SERVLET); return (srv == null) ? null : srv.getServletContext(); }
public static String getWebRootDir(ActionContext actionContext){ HttpServlet servlet = actionContext.getObject("servlet"); if(servlet != null){ return servlet.getServletContext().getRealPath("/"); }else{ return World.getInstance().getPath() + "/webroot/"; } } }
public void initialize(HttpServlet servlet) { ServletContext servletContext = servlet.getServletContext(); WebContext context = new ServletWebContext(servletContext); _globals.storeServletContext(servletContext); _globals.storeWebContext(context); }
public void initialize(HttpServlet servlet) { ServletContext servletContext = servlet.getServletContext(); WebContext context = new ServletWebContext(servletContext); _globals.storeServletContext(servletContext); _globals.storeWebContext(context); }
private IApplicationSpecification constructStandinSpecification(HttpServlet servlet) { String servletName = servlet.getServletName(); ApplicationSpecification result = new ApplicationSpecification(); // Pretend the file exists in the most common expected location. Resource virtualLocation = new ContextResource(servlet.getServletContext(), "/WEB-INF/" + servletName + ".application"); result.setSpecificationLocation(virtualLocation); result.setName(servletName); return result; }
private IApplicationSpecification constructStandinSpecification(HttpServlet servlet) { String servletName = servlet.getServletName(); ApplicationSpecification result = new ApplicationSpecification(); // Pretend the file exists in the most common expected location. Resource virtualLocation = new ContextResource(servlet.getServletContext(), "/WEB-INF/" + servletName + ".application"); result.setSpecificationLocation(virtualLocation); result.setName(servletName); return result; }