Example usage for javax.servlet.http HttpServlet getServletConfig

List of usage examples for javax.servlet.http HttpServlet getServletConfig

Introduction

In this page you can find the example usage for javax.servlet.http HttpServlet getServletConfig.

Prototype

public ServletConfig getServletConfig() 

Source Link

Document

Returns this servlet's ServletConfig object.

Usage

From source file:lucee.runtime.engine.CFMLEngineImpl.java

@Override
public void service(HttpServlet servlet, HttpServletRequest req, HttpServletResponse rsp)
        throws ServletException, IOException {
    CFMLFactory factory = getCFMLFactory(servlet.getServletConfig(), req);

    PageContext pc = factory.getLuceePageContext(servlet, req, rsp, null, false, -1, false, true, -1, true,
            false);//from  w  w w  . j  a  v  a 2s  .  c  o  m
    ThreadQueue queue = factory.getConfig().getThreadQueue();
    queue.enter(pc);
    try {
        pc.execute(pc.getHttpServletRequest().getServletPath(), false, true);
    } catch (PageException pe) {
        throw new PageServletException(pe);
    } finally {
        queue.exit(pc);
        factory.releaseLuceePageContext(pc, true);
        //FDControllerFactory.notifyPageComplete();
    }
}

From source file:lucee.runtime.engine.CFMLEngineImpl.java

@Override
public void serviceCFML(HttpServlet servlet, HttpServletRequest req, HttpServletResponse rsp)
        throws ServletException, IOException {
    CFMLFactory factory = getCFMLFactory(servlet.getServletConfig(), req);

    PageContext pc = factory.getLuceePageContext(servlet, req, rsp, null, false, -1, false, true, -1, true,
            false);/* w w w .  j  a  v  a 2s  . c o  m*/
    ThreadQueue queue = factory.getConfig().getThreadQueue();
    queue.enter(pc);
    try {
        /*print.out("INCLUDE");
        print.out("servlet_path:"+req.getAttribute("javax.servlet.include.servlet_path"));
        print.out("request_uri:"+req.getAttribute("javax.servlet.include.request_uri"));
        print.out("context_path:"+req.getAttribute("javax.servlet.include.context_path"));
        print.out("path_info:"+req.getAttribute("javax.servlet.include.path_info"));
        print.out("query_string:"+req.getAttribute("javax.servlet.include.query_string"));
        print.out("FORWARD");
        print.out("servlet_path:"+req.getAttribute("javax.servlet.forward.servlet_path"));
        print.out("request_uri:"+req.getAttribute("javax.servlet.forward.request_uri"));
        print.out("context_path:"+req.getAttribute("javax.servlet.forward.context_path"));
        print.out("path_info:"+req.getAttribute("javax.servlet.forward.path_info"));
        print.out("query_string:"+req.getAttribute("javax.servlet.forward.query_string"));
        print.out("---");
        print.out(req.getServletPath());
        print.out(pc.getHttpServletRequest().getServletPath());
        */

        pc.executeCFML(pc.getHttpServletRequest().getServletPath(), false, true);
    } catch (PageException pe) {
        throw new PageServletException(pe);
    } finally {
        queue.exit(pc);
        factory.releaseLuceePageContext(pc, true);
        //FDControllerFactory.notifyPageComplete();
    }
}

From source file:lucee.runtime.engine.CFMLEngineImpl.java

@Override
public void serviceRest(HttpServlet servlet, HttpServletRequest req, HttpServletResponse rsp)
        throws ServletException, IOException {
    req = new HTTPServletRequestWrap(req);
    CFMLFactory factory = getCFMLFactory(servlet.getServletConfig(), req);

    PageContext pc = factory.getLuceePageContext(servlet, req, rsp, null, false, -1, false, true, -1, true,
            false);//from  w  w  w .jav  a  2 s  . c o  m
    ThreadQueue queue = factory.getConfig().getThreadQueue();
    queue.enter(pc);
    try {
        pc.executeRest(pc.getHttpServletRequest().getServletPath(), false);
    } catch (PageException pe) {
        throw new PageServletException(pe);
    } finally {
        queue.exit(pc);
        factory.releaseLuceePageContext(pc, true);
        //FDControllerFactory.notifyPageComplete();
    }

}

From source file:lucee.runtime.engine.CFMLEngineImpl.java

@Override
public void serviceFile(HttpServlet servlet, HttpServletRequest req, HttpServletResponse rsp)
        throws ServletException, IOException {
    req = new HTTPServletRequestWrap(req);
    CFMLFactory factory = getCFMLFactory(servlet.getServletConfig(), req);
    ConfigWeb config = factory.getConfig();
    PageSource ps = config.getPageSourceExisting(null, null, req.getServletPath(), false, true, true, false);
    //Resource res = ((ConfigWebImpl)config).getPhysicalResourceExistingX(null, null, req.getServletPath(), false, true, true); 

    if (ps == null) {
        rsp.sendError(404);/*  w  w  w . ja  v  a  2  s.  co  m*/
    } else {
        Resource res = ps.getResource();
        if (res == null) {
            rsp.sendError(404);
        } else {
            ReqRspUtil.setContentLength(rsp, res.length());
            String mt = servlet.getServletContext().getMimeType(req.getServletPath());
            if (!StringUtil.isEmpty(mt))
                ReqRspUtil.setContentType(rsp, mt);
            IOUtil.copy(res, rsp.getOutputStream(), true);
        }
    }
}

From source file:net.jawr.web.bundle.processor.BundleProcessor.java

/**
 * Creates the bundles in the destination directory
 * //w  w w . j  a v a  2 s. com
 * @param servlet
 *            the servlet
 * @param bundleHandler
 *            the bundles handler
 * @param destDirPath
 *            the destination directory path
 * @param servletMapping
 *            the mapping of the servlet
 * @param keepUrlMapping
 *            the flag indicating if we must keep the URL mapping
 * @throws IOException
 *             if an IO exception occurs
 * @throws ServletException
 *             if a servlet exception occurs
 */
protected void createBundles(HttpServlet servlet, ResourceBundlesHandler bundleHandler, String destDirPath,
        String servletMapping, boolean keepUrlMapping) throws IOException, ServletException {

    List<JoinableResourceBundle> bundles = bundleHandler.getContextBundles();

    Iterator<JoinableResourceBundle> bundleIterator = bundles.iterator();
    MockServletResponse response = new MockServletResponse();
    MockServletRequest request = new MockServletRequest(JAWR_BUNDLE_PROCESSOR_CONTEXT_PATH);
    MockServletSession session = new MockServletSession(servlet.getServletContext());
    request.setSession(session);

    String resourceType = servlet.getServletConfig().getInitParameter(TYPE_INIT_PARAMETER);
    if (resourceType == null) {
        resourceType = JawrConstant.JS_TYPE;
    }

    // For the list of bundle defines, create the file associated
    while (bundleIterator.hasNext()) {
        JoinableResourceBundle bundle = (JoinableResourceBundle) bundleIterator.next();

        // Check if there is a resource file, which could be in conflict
        // with the bundle name
        URL url = servlet.getServletContext().getResource(bundle.getId());
        if (url != null) {
            logger.error(
                    "It is not recommended to use a bundle name which could be in conflict with a resource.\n"
                            + "Please rename your bundle '" + bundle.getId() + "' to avoid any issue");

        }

        List<Map<String, String>> allVariants = VariantUtils.getAllVariants(bundle.getVariants());

        if (allVariants == null) {
            allVariants = new ArrayList<Map<String, String>>();
        }

        if (allVariants.isEmpty()) {
            allVariants.add(new HashMap<String, String>());
        }
        // Creates the bundle file for each local variant
        for (Iterator<Map<String, String>> it = allVariants.iterator(); it.hasNext();) {
            Map<String, String> variantMap = (Map<String, String>) it.next();

            List<RenderedLink> linksToBundle = createLinkToBundle(bundleHandler, bundle.getId(), resourceType,
                    variantMap);
            for (Iterator<RenderedLink> iteratorLinks = linksToBundle.iterator(); iteratorLinks.hasNext();) {
                RenderedLink renderedLink = iteratorLinks.next();
                String path = renderedLink.getLink();

                // Force the debug mode of the config to match what was used
                // in the generated link
                JawrConfig config = bundleHandler.getConfig();
                config.setDebugModeOn(renderedLink.isDebugMode());

                String finalBundlePath = null;
                if (keepUrlMapping) {
                    finalBundlePath = path;
                } else {
                    finalBundlePath = getFinalBundlePath(path, config, variantMap);
                }

                // Sets the request URL
                setRequestUrl(request, variantMap, path, config);

                // We can't use path for generated resources because it's
                // not a valid file path ( /jawr_generator.js?xxx.... )
                if (!(path.indexOf("?") != -1) || !keepUrlMapping) {
                    File bundleFile = new File(destDirPath, finalBundlePath);
                    createBundleFile(servlet, response, request, path, bundleFile, servletMapping);
                }
            }
        }
    }
}

From source file:org.dmb.trueprice.utils.internal.InitContextListener.java

public static void getServletConfig(String servletName, HttpServlet servlet) {
    log.warn("\n\t >>> \t Servlet [" + servletName + "] request for config \n");
    log.warn("\n\t >>> \t Can we get it's init param names ? ["
            //                 + servletsContext.getServletRegistration(servletName).getInitParameters().keySet().toString()  + "] "                
            + servletsContext.containsKey(servletName) + "] "

    );// ww w .  j av a 2s.c om
    if (servletsContext.containsKey(servletName)) {
        log.debug("\t >>>\t SHOW INIT PARAMS of SERVLET CONTEXT");
        ServletConfig config = servlet.getServletConfig();
        Enumeration<String> e;
        try {
            e = config.getInitParameterNames();
            while (e.hasMoreElements()) {
                String attName = e.nextElement();
                String attValue = servlet.getInitParameter(attName).toString();
                log.info("New init param [" + (attName == null ? "???" : attName) + "] > "
                        + (attValue == null ? "???" : attValue));
            }
        } catch (Exception ex) {
            log.error("\t >>>\t        FAILURE       > " + ex.getMessage());
            ex.printStackTrace();
        }

    }
}

From source file:org.openbravo.authentication.AuthenticationManager.java

public void init(HttpServlet s) throws AuthenticationException {
    if (s instanceof ConnectionProvider) {
        conn = (ConnectionProvider) s;//w  ww. j a v  a2s.  c o m
    } else {
        conn = new DalConnectionProvider();
    }
    defaultServletUrl = s.getServletConfig().getServletContext().getInitParameter("ServletSinIdentificar");
}