Example usage for javax.servlet ServletContext getNamedDispatcher

List of usage examples for javax.servlet ServletContext getNamedDispatcher

Introduction

In this page you can find the example usage for javax.servlet ServletContext getNamedDispatcher.

Prototype

public RequestDispatcher getNamedDispatcher(String name);

Source Link

Document

Returns a RequestDispatcher object that acts as a wrapper for the named servlet.

Usage

From source file:org.debux.webmotion.server.WebMotionServer.java

/**
 * Action management in the mapping/* w w w . j  av  a  2s .c  o  m*/
 */
protected void doAction(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    long start = System.currentTimeMillis();

    // Create call context use in handler to get information on user request
    ServerContext serverContext = getServerContext(request);
    Call call = new Call(serverContext, request, response);

    // Apply config
    Mapping mapping = serverContext.getMapping();
    applyConfig(mapping, call);

    // Execute the main handler
    WebMotionHandler mainHandler = serverContext.getMainHandler();
    mainHandler.handle(mapping, call);

    // Register call in mbean
    ServerStats serverStats = serverContext.getServerStats();
    serverStats.registerCallTime(call, start);

    // Dispatch on servlet to manage websocket
    WebSocketInbound socket = (WebSocketInbound) request.getAttribute(WebSocketInbound.ATTRIBUTE_WEBSOCKET);
    if (socket != null) {
        ServletContext servletContext = request.getServletContext();
        RequestDispatcher dispatcher = servletContext.getNamedDispatcher(SERVLET_WEBSOCKET);
        dispatcher.forward(request, response);
    }
}

From source file:org.debux.webmotion.server.WebMotionServer.java

/**
 * Static resources management//from  w  w  w .  j a  va  2s  .co m
 */
protected void doResource(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    // Suppress the static in path
    HttpServletRequest requestWrapper = new HttpServletRequestWrapper(request) {
        @Override
        public String getServletPath() {
            String servletPath = super.getServletPath();
            if (servletPath != null) {
                return servletPath.replaceFirst(PATH_STATIC, "");
            }
            return null;
        }

        @Override
        public String getPathInfo() {
            String pathInfo = super.getPathInfo();
            if (pathInfo != null) {
                return pathInfo.replaceFirst(PATH_STATIC, "");
            }
            return null;
        }

        @Override
        public String getRequestURI() {
            String requestURI = super.getRequestURI();
            if (requestURI != null) {
                return requestURI.replaceFirst(PATH_STATIC, "");
            }
            return null;
        }
    };

    // Dispatch on default servlet
    ServletContext servletContext = request.getServletContext();
    RequestDispatcher dispatcher = servletContext.getNamedDispatcher("default");

    DispatcherType dispatcherType = request.getDispatcherType();
    if (dispatcherType == DispatcherType.INCLUDE) {
        dispatcher.include(requestWrapper, response);
    } else {
        dispatcher.forward(requestWrapper, response);
    }
}

From source file:org.b3log.latke.servlet.HTTPRequestDispatcher.java

/**
 * Initializes this servlet.//ww w  .j  av a  2s.c o m
 * 
 * <p>
 * Scans classpath for discovering request processors, configured the 'default' servlet for static resource processing.
 * </p>
 * 
 * @throws ServletException servlet exception
 * @see RequestProcessors#discover() 
 */
@Override
public void init() throws ServletException {
    Stopwatchs.start("Discovering Request Processors");
    try {
        LOGGER.info("Discovering request processors....");
        final String scanPath = getServletConfig().getInitParameter("scanPath");

        RequestProcessors.discover(scanPath);
        LOGGER.info("Discovered request processors");
    } catch (final Exception e) {
        LOGGER.log(Level.SEVERE, "Initializes request processors failed", e);
    } finally {
        Stopwatchs.end();
    }

    final ServletContext servletContext = getServletContext();

    if (servletContext.getNamedDispatcher(COMMON_DEFAULT_SERVLET_NAME) != null) {
        defaultServletName = COMMON_DEFAULT_SERVLET_NAME;
    } else if (servletContext.getNamedDispatcher(GAE_DEFAULT_SERVLET_NAME) != null) {
        defaultServletName = GAE_DEFAULT_SERVLET_NAME;
    } else if (servletContext.getNamedDispatcher(RESIN_DEFAULT_SERVLET_NAME) != null) {
        defaultServletName = RESIN_DEFAULT_SERVLET_NAME;
    } else if (servletContext.getNamedDispatcher(WEBLOGIC_DEFAULT_SERVLET_NAME) != null) {
        defaultServletName = WEBLOGIC_DEFAULT_SERVLET_NAME;
    } else if (servletContext.getNamedDispatcher(WEBSPHERE_DEFAULT_SERVLET_NAME) != null) {
        defaultServletName = WEBSPHERE_DEFAULT_SERVLET_NAME;
    } else {
        throw new IllegalStateException("Unable to locate the default servlet for serving static content. "
                + "Please set the 'defaultServletName' property explicitly.");
        // TODO: Loads from local.properties
    }

    LOGGER.log(Level.CONFIG, "The default servlet for serving static resource is [{0}]", defaultServletName);
}

From source file:edu.cornell.mannlib.vitro.webapp.filters.PageRoutingFilter.java

@Override
public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain chain)
        throws IOException, ServletException {
    ServletContext ctx = filterConfig.getServletContext();

    PageDao pageDao = ModelAccess.on(ctx).getWebappDaoFactory().getPageDao();
    Map<String, String> urlMappings = pageDao.getPageMappings();

    // get URL without hostname or servlet context
    HttpServletResponse response = (HttpServletResponse) arg1;
    HttpServletRequest req = (HttpServletRequest) arg0;
    String path = req.getRequestURI().substring(req.getContextPath().length());

    // check for first part of path
    // ex. /hats/superHat -> /hats
    Matcher m = urlPartPattern.matcher(path);
    if (m.matches() && m.groupCount() >= 1) {
        String path1stPart = m.group(1);
        String pageUri = urlMappings.get(path1stPart);

        //try it with a leading slash?
        if (pageUri == null)
            pageUri = urlMappings.get("/" + path1stPart);

        if (pageUri != null && !pageUri.isEmpty()) {
            log.debug(path + "is a request to a page defined in the display model as " + pageUri);

            //add the pageUri to the request scope for use by the PageController
            PageController.putPageUri(req, pageUri);

            //This will send requests to HomePageController or PageController
            String controllerName = getControllerToForwardTo(req, pageUri, pageDao);
            log.debug(path + " is being forwarded to controller " + controllerName);

            RequestDispatcher rd = ctx.getNamedDispatcher(controllerName);
            if (rd == null) {
                log.error(path + " should be forwarded to controller " + controllerName + " but there "
                        + "is no servlet named that defined for the web application in web.xml");
                //TODO: what should be done in this case?
            }/*w w  w. ja v a2 s .  c om*/

            rd.forward(req, response);
        } else if ("/".equals(path) || path.isEmpty()) {
            log.debug("url '" + path + "' is being forward to home controller");
            RequestDispatcher rd = ctx.getNamedDispatcher(HOME_CONTROLLER_NAME);
            rd.forward(req, response);
        } else {
            doNonDisplayPage(path, arg0, arg1, chain);
        }
    } else {
        doNonDisplayPage(path, arg0, arg1, chain);
    }
}

From source file:org.sakaiproject.tool.impl.ActiveToolComponent.java

/**
 * @inheritDoc/*from w ww .  j  a va  2 s.  c  om*/
 */
public void register(Tool tool, ServletContext context) {
    ActiveTool at = null;

    // make it an active tool
    if (tool instanceof MyActiveTool) {
        at = (MyActiveTool) tool;
    } else if (tool instanceof ActiveTool) {
        at = (ActiveTool) tool;
    } else {
        at = new MyActiveTool(tool);
    }

    // TODO: elevate setServletContext to ActiveTool interface to avoid instance testing
    if (at instanceof MyActiveTool) {
        ((MyActiveTool) at).setServletContext(context);
    }

    // KNL-409 - JSR-168 Portlets do not dispatch the same as normal
    // Sakai tools - so the warning below is not necessary for JSR-168
    // tools

    String portletContext = null;
    Properties toolProps = at.getFinalConfig();
    if (toolProps != null) {
        portletContext = toolProps.getProperty(TOOL_PORTLET_CONTEXT_PATH);
    }

    // KNL-352 - in Websphere ServletContext.getNamedDispatcher(...) will initialize the given Servlet.
    // However Websphere's normal Servlet initialization happens later at com.ibm.ws.wswebcontainer.webapp.WebApp.initialize(WebApp.java:293).
    // As a result, Websphere ends up trying to initialize the Servlet twice, causing the observed mapping clash exceptions.

    if (!"websphere".equals(serverConfigurationService().getString("servlet.container"))
            && portletContext == null) {
        // try getting the RequestDispatcher, just to test - but DON'T SAVE IT!
        // Tomcat's RequestDispatcher is NOT thread safe and must be gotten from the context
        // every time its needed!
        RequestDispatcher dispatcher = context.getNamedDispatcher(at.getId());
        if (dispatcher == null) {
            M_log.warn("missing dispatcher for tool: " + at.getId());
        }
    }

    m_tools.put(at.getId(), at);
}

From source file:servlets.LeasingControllerServlet.java

protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    try {/*  www. j  a  va  2 s  .  com*/
        RequestDispatcher dispatcher;
        ServletContext servletContext = getServletContext();
        String page = request.getPathInfo().substring(1);
        String mallName = (String) request.getSession().getAttribute("mallName");
        int numOfLevel;

        String staffPosition;
        String staffUserName;
        String levelCode;
        ArrayList<String> unitListToAddTenant;
        String leasingRequestType;
        Long leasingRequestId;
        ArrayList<LeasingSystemRequestEntity> requestList;
        boolean alreadyInitialized;
        TenantEntity tenant;
        ArrayList<TenantEntity> allTenantList;

        switch (page) {
        //START-FUNCTION FOR LEASING MANAGER
        case "ViewAllRequests":
            System.err.println("IT GOES HERE");
            page = "LeasingManagerViewAllRequests";
            break;
        case "ViewLeasingRequestDetail":
            leasingRequestId = Long.parseLong(request.getParameter("leasingRequestId"));
            leasingRequestType = determineLeasingRequestType(leasingRequestId, request);
            if (leasingRequestType.equals("FloorplanModify")) {
                request.getSession().setAttribute("levelCode", "LV1");
                page = "LeasingManagerReviewFloorPlanPrototype";
            }
            if (leasingRequestType.equals("CategoryModify")) {
                request.getSession().setAttribute("levelCode", "LV1");
                page = "LeasingManagerReviewCategoryPrototype";
            }
            if (leasingRequestType.equals("PublicOpenBid")) {
                request.getSession().setAttribute("levelCode", "LV1");
                LeasingSystemRequestEntity leasingRequestInstance = doGetLeasingRequestById(leasingRequestId);
                request.getSession().setAttribute("leasingRequestInstance", leasingRequestInstance);
                page = "LeasingManagerReviewOpenPublicBidPrototype";
            }
            if (leasingRequestType.equals("LongTermApplicationApproval")) {
                LongTermApplicationEntity longTermApplication = doGetLongTermApplication(request);
                request.setAttribute("longTermApplication", longTermApplication);
                page = "LeasingManagerReviewLongTermApplicationApproval";
            }
            if (leasingRequestType.equals("ContractRenewRequest")) {
                LeasingSystemRequestEntity leasingRequestInstance = doGetLeasingRequestById(leasingRequestId);
                request.setAttribute("leasingRequestInstance", leasingRequestInstance);
                TenantEntity tempRenewTenant = tenantManagerSessionLocal
                        .getTenantById(leasingRequestInstance.getApplicationId());
                request.setAttribute("renewTenant", tempRenewTenant);
                page = "LeasingManagerReviewContractRenewRequest";
            }
            break;
        case "ChangeFloorplanLevelReviewFloorPlanPrototype":
            levelCode = request.getParameter("levelCode");
            request.getSession().setAttribute("levelCode", levelCode);
            page = "LeasingManagerReviewFloorPlanPrototype";
            break;
        case "ChangeFloorplanLevelReviewCategoryPrototype":
            levelCode = request.getParameter("levelCode");
            request.getSession().setAttribute("levelCode", levelCode);
            page = "LeasingManagerReviewCategoryPrototype";
            break;
        case "ChangeFloorplanLevelReviewPublicOpenBidPrototype":
            levelCode = request.getParameter("levelCode");
            request.getSession().setAttribute("levelCode", levelCode);
            page = "LeasingManagerReviewOpenPublicBidPrototype";
            break;
        case "BackToViewAllLeasingRequests":
            page = "LeasingManagerViewAllRequests";
            break;
        case "AcceptLeasingRequest":
            leasingRequestId = Long.parseLong(request.getParameter("leasingRequestId"));
            leasingRequestType = determineLeasingRequestType(leasingRequestId, request);
            if (leasingRequestType.equals("FloorplanModify")) {
                doAcceptUpdateFloorPlanAndUpdateRequest(request);
                page = "LeasingManagerViewAllRequests";
            }
            if (leasingRequestType.equals("CategoryModify")) {
                doAcceptUpdateCategoryAndUpdateRequest(request);
                page = "LeasingManagerViewAllRequests";
            }
            if (leasingRequestType.equals("PublicOpenBid")) {
                doAcceptUpdateOpenBidAndUpdateRequest(request);
                page = "LeasingManagerViewAllRequests";
            }
            if (leasingRequestType.equals("LongTermApplicationApproval")) {
                doAcceptUpdateLongTermApplicationAndUpdateRequest(request);
                page = "LeasingManagerViewAllRequests";
            }
            if (leasingRequestType.equals("ContractRenewRequest")) {
                doAcceptContractRenewRequest(request);
                page = "LeasingManagerViewAllRequests";
            }
            break;
        case "RejectLeasingRequest":
            leasingRequestId = Long.parseLong(request.getParameter("leasingRequestId"));
            leasingRequestType = determineLeasingRequestType(leasingRequestId, request);
            if (leasingRequestType.equals("FloorplanModify")) {
                doRejectUpdateFloorPlanAndUpdateRequest(request);
                page = "LeasingManagerViewAllRequests";
            }
            if (leasingRequestType.equals("CategoryModify")
                    || leasingRequestType.equals("LongTermApplicationApproval")
                    || leasingRequestType.equals("ContractRenewRequest")) {
                doRejectUpdateRequest(request);
                page = "LeasingManagerViewAllRequests";
            }
            if (leasingRequestType.equals("PublicOpenBid")) {
                doRejectUpdateOpenBidAndUpdateRequest(request);
                page = "LeasingManagerViewAllRequests";
            }
            break;
        case "ViewTenantMixLM":
            request.getSession().setAttribute("levelCode", "LV1");
            request.getSession().removeAttribute("unitListToAddTenant");
            request.getSession().removeAttribute("errorMessage");
            page = "LeasingManagerViewTenantMix";
            break;
        case "ChangeLevelTenantMixLM":
            levelCode = request.getParameter("levelCode");
            request.getSession().setAttribute("levelCode", levelCode);
            request.getSession().removeAttribute("errorMessage");
            page = "LeasingManagerViewTenantMix";
            break;
        case "ViewCurrentTenantLM":
            allTenantList = doGetAllTenants(request);
            request.getSession().setAttribute("allTenantList", allTenantList);
            page = "LeasingManagerViewCurrentTenants";
            break;
        case "ViewTenantDetailLM":
            tenant = doGetTenantById(request);
            request.setAttribute("detailedTenant", tenant);
            page = "LeasingOfficerViewTenantDetail";
            break;

        //END-FUNCTION FOR LEASING MANAGER
        //START-FUNCTION FOR LEASING OFFICER
        case "LeasingOfficerMain":
            request.getSession().removeAttribute("unitListToAddTenant");
            request.getSession().removeAttribute("errorMessage");
            request.getSession().setAttribute("levelCode", "LV1");
            alreadyInitialized = doCheckInitialization(request);
            if (!alreadyInitialized) {
                request.setAttribute("errorMessage",
                        "Floorplan has not been initialized and therefore cannot be accessed");
                page = "leasingSystemError";
            } else {
                page = "LeasingOfficerZoneDeclare";
            }
            break;
        case "DeclareZone":
            request.getSession().setAttribute("levelCode", "LV1");
            page = "LeasingOfficerZoneDeclare";
            break;
        case "SaveStoreZonePrototypeCategory":
            String saveZoneStatus = doSaveStoreZonePrototypeCategory(request);
            request.setAttribute("saveZoneStatus", saveZoneStatus);
            page = "LeasingOfficerZoneDeclare";
            break;
        case "SavePushCartOrKioskPrototypeCategory":
            String savePushCartOrKioskStatus = doSavePushCartOrKioskPrototypeCategory(request);
            page = "LeasingOfficerZoneDeclare";
            break;
        case "ChangeFloorplanLevelZoneDeclare":
            levelCode = request.getParameter("levelCode");
            request.getSession().setAttribute("levelCode", levelCode);
            page = "LeasingOfficerZoneDeclare";
            break;
        case "AddUnitToListToAddTenant":
            String chooseUnitStatus = doAddUnitsToListToAddTenant(request);
            request.setAttribute("chooseUnitStatus", chooseUnitStatus);
            page = "LeasingOfficerChooseUnitForPublicBidding";
            break;

        case "ChooseUnitForPublicBidding":
            request.getSession().setAttribute("levelCode", "LV1");
            request.getSession().removeAttribute("unitListToAddTenant");
            request.getSession().removeAttribute("errorMessage");
            page = "LeasingOfficerChooseUnitForPublicBidding";
            break;
        case "ChangeFloorplanLevelChooseUnitPublicBidding":
            levelCode = request.getParameter("levelCode");
            request.getSession().setAttribute("levelCode", levelCode);
            request.getSession().removeAttribute("errorMessage");
            page = "LeasingOfficerChooseUnitForPublicBidding";
            break;
        //this code will reuse unitListToAddTenant for convenience
        //this list is generated in AddUnitToListToAddTenant
        case "RequestOpenUnitForPublicBidding":
            doSetOpenPublicBiddingPrototype(request);
            page = "LeasingOfficerComposePublicOpenBidRequest";
            break;
        case "SendPublicOpenBidRequest":
            doSendPublicOpenBidRequest(request);
            request.setAttribute("sendRequestStatus", "Your request has successfully been sent");
            request.getSession().setAttribute("levelCode", "LV1");
            page = "LeasingOfficerZoneDeclare";
            break;

        case "ViewAllTenants":
            allTenantList = doGetAllTenants(request);
            request.getSession().setAttribute("allTenantList", allTenantList);
            page = "LeasingOfficerViewAllTenants";
            break;
        case "ViewTenantDetail":
            tenant = doGetTenantById(request);
            request.setAttribute("detailedTenant", tenant);
            page = "LeasingOfficerViewTenantDetail";
            break;
        case "ComposeCategoryRequest":
            page = "LeasingOfficerComposeCategoryRequest";
            break;
        case "SendCategoryRequest":
            doSendCategoryRequest(request);
            request.setAttribute("sendRequestStatus", "Your request has successfully been sent");
            page = "LeasingOfficerZoneDeclare";
            break;
        case "ViewAllPublicLongTermApplication":
            page = "LeasingOfficerViewAllPublicLongTerm";
            break;
        case "PrepareContractForLongTermApplicant":
            Long applicantId = Long.parseLong(request.getParameter("applicantId"));
            request.getSession().setAttribute("applicantId", applicantId);
            page = "LeasingOfficerPrepareLongTermContract";
            break;
        case "ComposeLongTermApplicationRequest":
            doProposeLongTermApplication(request);
            page = "LeasingOfficerComposeLongTermApplicationRequest";
            break;
        case "SendLongTermApplicationApprovalRequest":
            doSendLongTermApplicationApprovalRequest(request);
            request.setAttribute("sendRequestStatus", "Your request has successfully been sent");
            page = "LeasingOfficerZoneDeclare";
            break;
        case "CheckLeasingOfficerRequestStatus":
            requestList = doGetRequestsByUserName(request);
            request.setAttribute("requestList", requestList);
            page = "LeasingOfficerCheckRequest";
            break;
        case "DeleteLeasingOfficerRequest":
            doDeleteLeasingRequestById(request);
            request.setAttribute("deleteRequestStatus", "Your request has successfully been deleted");
            requestList = doGetRequestsByUserName(request);
            request.setAttribute("requestList", requestList);
            page = "LeasingOfficerCheckRequest";
            break;

        /////case of delete and (function)list request is on space planner side
        case "ViewExpiringTenant":
            page = "LeasingOfficerViewExpiringTenant";
            break;
        case "SendContractRenewalEmail":
            int success = doSendContractRenewalEmail(request);
            if (success == 0) {
                request.setAttribute("ContractRenewEmailStatus", "Contract renewal email has been sent");
            } else {
                request.setAttribute("ContractRenewEmailStatus", "Error while sending email");
            }
            page = "LeasingOfficerViewExpiringTenant";
            break;
        case "RenewContract":
            TenantEntity renewTenant = tenantManagerSessionLocal
                    .getTenantById(Long.parseLong(request.getParameter("tenantId")));
            request.getSession().setAttribute("renewTenant", renewTenant);
            page = "LeasingOfficerRenewContract";
            break;
        case "ProposeContractRenew":
            String renewProposeStatus = doProposeRenew(request);
            request.setAttribute("renewProposeStatus", renewProposeStatus);
            page = "LeasingOfficerViewExpiringTenant";
            break;

        case "ViewEventApplication":
            page = "LeasingOfficerViewAllEventApplication";
            break;
        case "AcceptEventApplication":
            EventEntity event = doGetEventById(request);
            request.setAttribute("event", event);
            page = "LeasingOfficerPrepareEventContract";
            break;
        case "PersistEventApplicationAcceptance":
            String acceptEventStatus = doAcceptEventApplication(request);
            request.setAttribute("acceptEventStatus", acceptEventStatus);
            page = "LeasingOfficerViewAllEventApplication";
            break;
        case "ViewAllEvent":
            page = "LeasingOfficerViewAllEvent";
            break;
        case "DeleteEvent":
            String deleteEventStatus = doDeleteEventWithId(request);
            request.setAttribute("deleteEventStatus", deleteEventStatus);
            page = "LeasingOfficerViewAllEvent";
            break;
        case "ViewPendingTenant":
            //pendingList in ESSENTIAL ZONE
            page = "LeasingOfficerViewPendingTenant";
            break;
        case "OfficializePendingTenant":
            String officializeStatus = doOfficializePendingTenant(request);
            request.setAttribute("officializeStatus", officializeStatus);
            page = "LeasingOfficerViewPendingTenant";
            break;
        case "DeleteExpireTenant":
            String deleteTenantStatus = doDeleteExpireTenant(request);
            request.setAttribute("deleteTenantStatus", deleteTenantStatus);
            page = "LeasingOfficerViewExpiringTenant";
            break;
        case "ViewTenantRequest":
            getRentReqList(request);
            page = "LeasingOfficerViewAllRentRequest";
            break;
        case "AcceptRentRequest":
            changeRentReqStatus(request, "Accepted");
            getRentReqList(request);
            page = "LeasingOfficerViewAllRentRequest";
            break;
        case "RejectRentRequest":
            changeRentReqStatus(request, "Rejected");
            getRentReqList(request);
            page = "LeasingOfficerViewAllRentRequest";
            break;
        //END-FUNCTION FOR LEASING OFFICER
        //START-FUNCTION FOR SPACE PLAN OFFICER
        case "SpacePlanMain":
            alreadyInitialized = doCheckInitialization(request);
            if (!alreadyInitialized) {
                page = "SpacePlanDeclare";
            } else {
                page = "SpacePlanLocate";
                request.getSession().setAttribute("levelCode", "LV1");
            }
            request.getSession().setAttribute("actionToTake", "UploadFloorplanBackground");
            //if already initialized, then go straight to main menu
            break;
        case "InitializeSpacePlan":
            request.getSession().setAttribute("actionToTake", "DeclareNumOfLevel");
            page = "SpacePlanDeclare";
            break;
        case "DeclareNumOfLevel":
            if (request.getParameter("numOfLevel") != null) {
                String numOfLevelString = (String) request.getParameter("numOfLevel");
                numOfLevel = Integer.valueOf(numOfLevelString.trim());
                request.getSession().setAttribute("numOfLevel", numOfLevel);
            }
            request.getSession().setAttribute("actionToTake", "DeclareNumOfUnitPerLevel");
            page = "SpacePlanDeclare";
            break;
        case "DeclareNumOfUnitPerLevel":
            ArrayList<ArrayList<String>> levelNameNumUnitList = doGetLevelNameNumUnitList(request);
            request.getSession().setAttribute("levelNameNumUnitList", levelNameNumUnitList);
            for (int i = 0; i < levelNameNumUnitList.size(); i++) {
                ArrayList<String> test = levelNameNumUnitList.get(i);
            }
            request.getSession().setAttribute("actionToTake", "DeclareFloorplanBackground");
            page = "SpacePlanDeclare";
            break;
        case "DeclareFloorplanBackground":
            ArrayList<ArrayList<String>> levelNameNumUnitBackgroundList = doGetLevelNameNumUnitBackgroundList(
                    request);
            request.getSession().setAttribute("levelNameNumUnitBackgroundList", levelNameNumUnitBackgroundList);
            request.getSession().setAttribute("actionToTake", "FinalConfirmation");
            page = "SpacePlanDeclare";
            break;
        case "DeclareAgain":
            request.getSession().setAttribute("actionToTake", "DeclareNumOfLevel");
            page = "SpacePlanDeclare";
            break;
        case "SaveUnitPosition":
            doAddLocalStorageInfo(request);
            page = "SpacePlanLocate";
            break;
        case "FinalConfirmation":
            doCreateAllUnit(request);
            request.getSession().setAttribute("levelCode", "LV1");
            page = "SpacePlanLocate";
            break;
        //////////////////////////////////ACCESS ONLY FOR REPOSITION
        case "LocateSpacePlan":
            if (request.getSession().getAttribute("levelCode") == null) {
                request.getSession().setAttribute("levelCode", "LV1");
            }
            page = "SpacePlanLocate";
            break;
        case "ChangeFloorplanLevelSpacePlanning":
            levelCode = request.getParameter("levelCode");
            request.getSession().setAttribute("levelCode", levelCode);
            page = "SpacePlanLocate";
            break;
        case "AddPushCart":
            page = "SpacePlanPushCartDeclare";
            break;
        case "AddKiosk":
            page = "SpacePlanKioskDeclare";
            break;
        case "AddNumOfKioskPerLevel":
            doAddNumOfKioskPerLevel(request);
            page = "SpacePlanLocate";
            break;
        case "AddEvent":
            page = "SpacePlanEventDeclare";
            break;
        case "AddNumOfEventPerLevel":
            doAddNumOfEventPerLevel(request);
            page = "SpacePlanLocate";
            break;
        case "AddStore":
            page = "SpacePlanStoreDeclare";
            break;
        case "AddNumOfStorePerLevel":
            doAddNumOfStorePerLevel(request);
            page = "SpacePlanLocate";
            break;
        case "AddNumOfPushCartPerLevel":
            doAddNumOfPushCartPerLevel(request);
            page = "SpacePlanLocate";
            break;

        case "ComposeFloorplanRequest":
            page = "SpacePlanComposeRequest";
            break;
        case "SendFloorplanRequest":
            doSendFloorplanRequest(request);
            request.setAttribute("sendRequestStatus", "Your request has successfully been sent");
            page = "SpacePlanLocate";
            break;
        case "ProposeDeleteSingleUnit":
            request.setAttribute("unitDeleteStatus", doSetUnitDelete(request));
            page = "SpacePlanLocate";
            break;
        case "CheckSpacePlanRequestStatus":
            requestList = doGetRequestsByUserName(request);
            request.setAttribute("requestList", requestList);
            page = "SpacePlanCheckRequest";
            break;
        case "DeleteFloorPlanRequest":
            doDeleteLeasingRequestById(request);
            request.setAttribute("deleteRequestStatus", "Your request has successfully been deleted");
            requestList = doGetRequestsByUserName(request);
            request.setAttribute("requestList", requestList);
            page = "SpacePlanCheckRequest";
            break;
        }

        //END-FUNCTION FOR SPACE PLAN OFFICER
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////START ESSENTIALS ZONE///////////////////////////////////////////////////////////
        if (page.equals("LeasingOfficerViewAllEvent")) {
            ArrayList<EventEntity> allEventList = doGetAllEvent(request);
            request.setAttribute("allEventList", allEventList);
        }
        if (page.equals("LeasingOfficerViewAllEventApplication")) {
            ArrayList<EventEntity> eventApplicationList = doGetAllEventApplication(request);
            request.setAttribute("eventApplicationList", eventApplicationList);
        }
        if (page.equals("LeasingOfficerViewPendingTenant")) {
            ArrayList<TenantEntity> pendingTenantList = doGetAllPendingTenant(request);
            request.setAttribute("pendingTenantList", pendingTenantList);
        }
        if (page.equals("LeasingOfficerViewExpiringTenant")) {
            ArrayList<Object[]> expiringTenantList = doGetExpiringTenant(request);
            request.setAttribute("expiringTenantList", expiringTenantList);
        }
        if (page.equals("LeasingOfficerChooseUnitForTenant")
                || page.equals("LeasingOfficerChooseUnitForPublicBidding")
                || page.equals("LeasingManagerViewTenantMix")) {
            numOfLevel = doGetNumOfLevel((String) request.getSession().getAttribute("mallName"));
            request.getSession().setAttribute("numOfLevel", numOfLevel);
            Vector unitColorVector = doGetAllUnitColorForCurrentMall(request);
            request.getSession().setAttribute("unitColorVector", unitColorVector);
        }
        if (page.equals("LeasingOfficerZoneDeclare") || page.equals("LeasingManagerReviewCategoryPrototype")
                || page.equals("LeasingManagerReviewOpenPublicBidPrototype")) {
            numOfLevel = doGetNumOfLevel((String) request.getSession().getAttribute("mallName"));
            request.getSession().setAttribute("numOfLevel", numOfLevel);
            Vector unitColorVector = doGetAllPrototypeUnitColorForCurrentMall(request);
            request.setAttribute("unitColorVector", unitColorVector);
        }
        if (page.equals("SpacePlanLocate") || page.equals("LeasingOfficerZoneDeclare")
                || page.equals("LeasingOfficerChooseUnitForTenant")
                || page.equals("LeasingManagerReviewFloorPlanPrototype")
                || page.equals("LeasingManagerReviewCategoryPrototype")
                || page.equals("LeasingOfficerChooseUnitForPublicBidding")
                || page.equals("LeasingManagerReviewOpenPublicBidPrototype")
                || page.equals("LeasingManagerViewTenantMix")) {
            numOfLevel = doGetNumOfLevel((String) request.getSession().getAttribute("mallName"));
            request.getSession().setAttribute("numOfLevel", numOfLevel);
            LevelEntity levelInstance = doGetLevel(request);
            request.getSession().setAttribute("levelInstance", levelInstance);
        }
        if (page.equals("LeasingManagerViewAllRequests")) {
            numOfLevel = doGetNumOfLevel((String) request.getSession().getAttribute("mallName"));
            request.getSession().setAttribute("numOfLevel", numOfLevel);
            ArrayList<LeasingSystemRequestEntity> leasingRequestList = doGetListOfAllLeasingRequests(request);
            request.getSession().setAttribute("leasingRequestList", leasingRequestList);
        }
        if (page.equals("LeasingOfficerViewAllPublicLongTerm")) {
            numOfLevel = doGetNumOfLevel((String) request.getSession().getAttribute("mallName"));
            request.getSession().setAttribute("numOfLevel", numOfLevel);
            ArrayList<LongTermApplicationEntity> longTermApplicationList = doGetLongTermApplicationList(
                    request);
            request.setAttribute("longTermApplicationList", longTermApplicationList);
        }

        dispatcher = servletContext.getNamedDispatcher(page);
        dispatcher.forward(request, response);
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////END ESSENTIALS ZONE///////////////////////////////////////////////////////////
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}