Example usage for javax.servlet.http HttpServlet service

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

Introduction

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

Prototype

@Override
public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException 

Source Link

Document

Dispatches client requests to the protected service method.

Usage

From source file:org.openmrs.module.web.ModuleServlet.java

@Override
protected void service(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    log.debug("In service method for module servlet: " + request.getPathInfo());
    String servletName = request.getPathInfo();
    int end = servletName.indexOf("/", 1);

    String moduleId = null;//from   w ww.j ava2  s  . com
    if (end > 0) {
        moduleId = servletName.substring(1, end);
    }

    log.debug("ModuleId: " + moduleId);
    Module mod = ModuleFactory.getModuleById(moduleId);

    int start = 1; // where in the path to start trimming
    if (mod != null) {
        log.debug("Module with id " + moduleId + " found.  Looking for servlet name after " + moduleId
                + " in url path");
        start = moduleId.length() + 2;
        // this skips over the moduleId that is in the path
    }

    end = servletName.indexOf("/", start);
    if (end == -1 || end > servletName.length()) {
        end = servletName.length();
    }
    servletName = servletName.substring(start, end);

    log.debug("Servlet name: " + servletName);

    HttpServlet servlet = WebModuleUtil.getServlet(servletName);

    if (servlet == null) {
        log.warn("No servlet with name: " + servletName + " was found");
        response.setStatus(HttpServletResponse.SC_NOT_FOUND);
        return;
    }

    servlet.service(request, response);
}

From source file:org.vosao.filter.SiteFilter.java

private boolean processPluginServlet(ServletRequest request, ServletResponse response)
        throws ServletException, IOException {
    HttpServlet servlet = getBusiness().getPluginBusiness().getPluginServlet((HttpServletRequest) request);
    if (servlet != null) {
        servlet.service(request, response);
        return true;
    }/*from  ww w  .  j ava  2  s  .  c o  m*/
    return false;
}