Java Code Examples for javax.servlet.ServletContext#getServletRegistration()

The following examples show how to use javax.servlet.ServletContext#getServletRegistration() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: packagedrone   File: TldScanner.java    License: Eclipse Public License 1.0 6 votes vote down vote up
public void onStartup(java.util.Set<java.lang.Class<?>> c,
           ServletContext ctxt) throws ServletException {
    this.ctxt = ctxt;
    Boolean b = (Boolean) ctxt.getAttribute("com.sun.faces.useMyFaces");
    if (b != null) {
        useMyFaces = b.booleanValue();
    }
    ServletRegistration reg = ctxt.getServletRegistration("jsp");
    if (reg == null) {
        return;
    }
    String validating = reg.getInitParameter("validating");
    isValidationEnabled = "true".equals(validating);

    scanListeners = true;
    scanTlds();

    ctxt.setAttribute(Constants.JSP_TLD_URI_TO_LOCATION_MAP, mappings);
}
 
Example 2
Source Project: oxAuth   File: ConfigurationFactory.java    License: MIT License 6 votes vote down vote up
public void onServletContextActivation(@Observes ServletContext context ) {
   this.contextPath = context.getContextPath();

   this.facesMapping = "";
   ServletRegistration servletRegistration = context.getServletRegistration("Faces Servlet");
   if (servletRegistration == null) {
   	return;
   }

   String[] mappings = servletRegistration.getMappings().toArray(new String[0]);
   if (mappings.length == 0) {
       return;
   }
   
   this.facesMapping = mappings[0].replaceAll("\\*", "");
}
 
Example 3
Source Project: myspring   File: DispatcherServlet.java    License: MIT License 5 votes vote down vote up
@Override
public void init(ServletConfig config) throws ServletException {

	Object oldCxt = config.getServletContext().getAttribute(ContextLoaderListener.ROOT_CXT_ATTR);
	this.context = oldCxt == null ? new WebApplicationContext() : (WebApplicationContext)oldCxt;

	ServletContext sc = config.getServletContext();
	
       //注册JSP的Servlet,视图才能重定向
       ServletRegistration jspServlet = sc.getServletRegistration("jsp");
       jspServlet.addMapping(CommonUtis.JSP_PATH_PREFIX + "*");
}
 
Example 4
Source Project: bfmvc   File: DispatherServlet.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void init(ServletConfig config) throws ServletException {
    Loader.init();//初始化框架&应用
    ServletContext sc = config.getServletContext();
    //注册JSP的Servlet
    ServletRegistration jspServlet = sc.getServletRegistration("jsp");
    jspServlet.addMapping(ConfigHelper.getAppJspPath() + "*");
    //注册处理静态资源的Servlet
    ServletRegistration defaultServlet = sc.getServletRegistration("default");
    defaultServlet.addMapping(ConfigHelper.getAppAssetPath() + "*");
}
 
Example 5
private void registerDefaultServlet(ServletContext context) {
    ServletRegistration defaultServlet = context.getServletRegistration("default");
    defaultServlet.addMapping("/index.html");
    defaultServlet.addMapping("/favicon.ico");
    String wwwPath = FrameworkConstant.WWW_PATH;
    if (StringUtil.isNotEmpty(wwwPath)) {
        defaultServlet.addMapping(wwwPath + "*");
    }
}
 
Example 6
private void registerJspServlet(ServletContext context) {
    ServletRegistration jspServlet = context.getServletRegistration("jsp");
    jspServlet.addMapping("/index.jsp");
    String jspPath = FrameworkConstant.JSP_PATH;
    if (StringUtil.isNotEmpty(jspPath)) {
        jspServlet.addMapping(jspPath + "*");
    }
}
 
Example 7
private void registerDefaultServlet(ServletContext context) {
    ServletRegistration defaultServlet = context.getServletRegistration("default");
    defaultServlet.addMapping("/index.html");
    defaultServlet.addMapping("/favicon.ico");
    String wwwPath = FrameworkConstant.WWW_PATH;
    if (StringUtil.isNotEmpty(wwwPath)) {
        defaultServlet.addMapping(wwwPath + "*");
    }
}
 
Example 8
private void registerJspServlet(ServletContext context) {
    ServletRegistration jspServlet = context.getServletRegistration("jsp");
    jspServlet.addMapping("/index.jsp");
    String jspPath = FrameworkConstant.JSP_PATH;
    if (StringUtil.isNotEmpty(jspPath)) {
        jspServlet.addMapping(jspPath + "*");
    }
}
 
Example 9
private String getServletMapping(final ServletContext ctx, final String name) throws ServletException {
    ServletRegistration sr = ctx.getServletRegistration(name);
    if (sr != null) {
        return sr.getMappings().iterator().next();
    }
    final String error = "Servlet with a name " + name + " is not available";
    throw new ServletException(error);
}
 
Example 10
Source Project: scipio-erp   File: ServletUtil.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Returns all servlet mappings for the given servlet name.
 */
public static Collection<String> getServletMappings(ServletContext servletContext, String servletName) {
    ServletRegistration reg = servletContext.getServletRegistration(servletName);
    if (reg == null) return null;
    return reg.getMappings();
}