Example usage for javax.servlet.http HttpServletRequest getServerPort

List of usage examples for javax.servlet.http HttpServletRequest getServerPort

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletRequest getServerPort.

Prototype

public int getServerPort();

Source Link

Document

Returns the port number to which the request was sent.

Usage

From source file:fr.xebia.servlet.filter.XForwardedFilterTest.java

/**
 * Test {@link XForwardedFilter} in Jetty
 *//*w w w  .j a  v  a 2  s  .com*/
@Test
public void testWithJetty() throws Exception {

    // SETUP
    int port = 6666;
    Server server = new Server(port);
    Context context = new Context(server, "/", Context.SESSIONS);

    // mostly default configuration : enable "x-forwarded-proto"
    XForwardedFilter xforwardedFilter = new XForwardedFilter();
    MockFilterConfig filterConfig = new MockFilterConfig();
    filterConfig.addInitParameter(XForwardedFilter.PROTOCOL_HEADER_PARAMETER, "x-forwarded-proto");
    // Following is needed on ipv6 stacks..
    filterConfig.addInitParameter(XForwardedFilter.INTERNAL_PROXIES_PARAMETER,
            InetAddress.getByName("localhost").getHostAddress());
    xforwardedFilter.init(filterConfig);
    context.addFilter(new FilterHolder(xforwardedFilter), "/*", Handler.REQUEST);

    MockHttpServlet mockServlet = new MockHttpServlet();
    context.addServlet(new ServletHolder(mockServlet), "/test");

    server.start();
    try {
        // TEST
        HttpURLConnection httpURLConnection = (HttpURLConnection) new URL("http://localhost:" + port + "/test")
                .openConnection();
        String expectedRemoteAddr = "my-remote-addr";
        httpURLConnection.addRequestProperty("x-forwarded-for", expectedRemoteAddr);
        httpURLConnection.addRequestProperty("x-forwarded-proto", "https");

        // VALIDATE

        Assert.assertEquals(HttpURLConnection.HTTP_OK, httpURLConnection.getResponseCode());
        HttpServletRequest request = mockServlet.getRequest();
        Assert.assertNotNull(request);

        // VALIDATE X-FOWARDED-FOR
        Assert.assertEquals(expectedRemoteAddr, request.getRemoteAddr());
        Assert.assertEquals(expectedRemoteAddr, request.getRemoteHost());

        // VALIDATE X-FORWARDED-PROTO
        Assert.assertTrue(request.isSecure());
        Assert.assertEquals("https", request.getScheme());
        Assert.assertEquals(443, request.getServerPort());
    } finally {
        server.stop();
    }
}

From source file:com.cyclopsgroup.waterview.servlet.ServletPageRuntime.java

/**
 * Default constructor of default web runtime
 * /*from  www  .j a  v  a2 s  .c om*/
 * @param request Http request object
 * @param response Http response object
 * @param fileUpload File upload component
 * @param services ServiceManager object
 * @throws Exception Throw it out
 */
ServletPageRuntime(HttpServletRequest request, HttpServletResponse response, FileUpload fileUpload,
        ServiceManager services) throws Exception {
    this.response = response;
    this.request = request;
    setSessionContext(new HttpSessionContext(request.getSession()));

    String requestPath = request.getPathInfo();
    if (StringUtils.isEmpty(requestPath) || requestPath.equals("/")) {
        requestPath = "Index.jelly";
    } else if (requestPath.charAt(0) == '/') {
        requestPath = requestPath.substring(1);
    }
    setRequestPath(requestPath);

    setOutput(new PrintWriter(response.getOutputStream()));
    if (FileUpload.isMultipartContent(request)) {
        setRequestParameters(new MultipartServletRequestValueParser(request, fileUpload));
    } else {
        setRequestParameters(new ServletRequestValueParser(request));
    }
    setServiceManager(services);

    StringBuffer sb = new StringBuffer(request.getScheme());
    sb.append("://").append(request.getServerName());
    if (request.getServerPort() != 80) {
        sb.append(':').append(request.getServerPort());
    }
    sb.append(request.getContextPath());
    setApplicationBaseUrl(sb.toString());

    sb.append(request.getServletPath());
    setPageBaseUrl(sb.toString());

    Context pageContext = new DefaultContext(new HashMap());
    pageContext.put("request", request);
    pageContext.put("response", response);
    setPageContext(pageContext);
}

From source file:com.rapid.actions.Webservice.java

@Override
public JSONObject doAction(RapidRequest rapidRequest, JSONObject jsonAction) throws Exception {

    _logger.trace("Webservice action : " + jsonAction);

    // get the application
    Application application = rapidRequest.getApplication();

    // get the page
    Page page = rapidRequest.getPage();//ww  w  . j a  va2  s .  com

    // get the webservice action call sequence
    int sequence = jsonAction.optInt("sequence", 1);

    // placeholder for the object we're about to return
    JSONObject jsonData = null;

    // only proceed if there is a request and application and page
    if (_request != null && application != null && page != null) {

        // get any json inputs 
        JSONArray jsonInputs = jsonAction.optJSONArray("inputs");

        // placeholder for the action cache
        ActionCache actionCache = rapidRequest.getRapidServlet().getActionCache();

        // if an action cache was found
        if (actionCache != null) {

            // log that we found action cache
            _logger.debug("Webservice action cache found");

            // attempt to fetch data from the cache
            jsonData = actionCache.get(application.getId(), getId(), jsonInputs.toString());

        }

        // if there is either no cache or we got no data
        if (jsonData == null) {

            // get the body into a string
            String body = _request.getBody().trim();
            // remove prolog if present
            if (body.indexOf("\"?>") > 0)
                body = body.substring(body.indexOf("\"?>") + 3).trim();
            // check number of parameters
            int pCount = Strings.occurrences(body, "?");
            // throw error if incorrect
            if (pCount != jsonInputs.length())
                throw new Exception("Request has " + pCount + " parameter" + (pCount == 1 ? "" : "s") + ", "
                        + jsonInputs.length() + " provided");
            // retain the current position
            int pos = body.indexOf("?");
            // keep track of the index of the ?
            int index = 0;
            // if there are any question marks
            if (pos > 0 && jsonInputs.length() > index) {
                // loop, but check condition at the end
                do {
                    // get the input
                    JSONObject input = jsonInputs.getJSONObject(index);
                    // url escape the value
                    String value = XML.escape(input.optString("value"));
                    // replace the ? with the input value
                    body = body.substring(0, pos) + value + body.substring(pos + 1);
                    // look for the next question mark
                    pos = body.indexOf("?", pos + 1);
                    // inc the index for the next round
                    index++;
                    // stop looping if no more ?
                } while (pos > 0);
            }

            // retrieve the action
            String action = _request.getAction();
            // create a placeholder for the request url
            URL url = null;
            // get the request url
            String requestURL = _request.getUrl();

            // if we got one
            if (requestURL != null) {

                // if the given request url starts with http use it as is, otherwise use the soa servlet
                if (_request.getUrl().startsWith("http")) {
                    // trim it
                    requestURL = requestURL.trim();
                    // insert any parameters
                    requestURL = application
                            .insertParameters(rapidRequest.getRapidServlet().getServletContext(), requestURL);
                    // use the url 
                    url = new URL(requestURL);
                } else {
                    // get our request
                    HttpServletRequest httpRequest = rapidRequest.getRequest();
                    // make a url for the soa servlet
                    url = new URL(httpRequest.getScheme(), httpRequest.getServerName(),
                            httpRequest.getServerPort(), httpRequest.getContextPath() + "/soa");
                    // check whether we have any id / version seperators
                    String[] actionParts = action.split("/");
                    // add this app and version if none
                    if (actionParts.length < 2)
                        action = application.getId() + "/" + application.getVersion() + "/" + action;
                }

                // establish the connection
                HttpURLConnection connection = (HttpURLConnection) url.openConnection();

                // if we are requesting from ourself
                if (url.getPath().startsWith(rapidRequest.getRequest().getContextPath())) {
                    // get our session id
                    String sessionId = rapidRequest.getRequest().getSession().getId();
                    // add it to the call for internal authentication
                    connection.setRequestProperty("Cookie", "JSESSIONID=" + sessionId);
                }

                // set the content type and action header accordingly
                if ("SOAP".equals(_request.getType())) {
                    connection.setRequestProperty("Content-Type", "text/xml");
                    connection.setRequestProperty("SOAPAction", action);
                } else if ("JSON".equals(_request.getType())) {
                    connection.setRequestProperty("Content-Type", "application/json");
                    if (action.length() > 0)
                        connection.setRequestProperty("Action", action);
                } else if ("XML".equals(_request.getType())) {
                    connection.setRequestProperty("Content-Type", "text/xml");
                    if (action.length() > 0)
                        connection.setRequestProperty("Action", action);
                }

                // if a body has been specified
                if (body.length() > 0) {

                    // Triggers POST.
                    connection.setDoOutput(true);

                    // get the output stream from the connection into which we write the request
                    OutputStream output = connection.getOutputStream();

                    // write the processed body string into the request output stream
                    output.write(body.getBytes("UTF8"));
                }

                // check the response code
                int responseCode = connection.getResponseCode();

                // read input stream if all ok, otherwise something meaningful should be in error stream
                if (responseCode == 200) {

                    // get the input stream
                    InputStream response = connection.getInputStream();
                    // prepare an soaData object
                    SOAData soaData = null;

                    // read the response accordingly
                    if ("JSON".equals(_request.getType())) {
                        SOAJSONReader jsonReader = new SOAJSONReader();
                        String jsonResponse = Strings.getString(response);
                        soaData = jsonReader.read(jsonResponse);
                    } else {
                        SOAXMLReader xmlReader = new SOAXMLReader(_request.getRoot());
                        soaData = xmlReader.read(response);
                    }

                    SOADataWriter jsonWriter = new SOARapidWriter(soaData);

                    String jsonString = jsonWriter.write();

                    jsonData = new JSONObject(jsonString);

                    if (actionCache != null)
                        actionCache.put(application.getId(), getId(), jsonInputs.toString(), jsonData);

                    response.close();

                } else {

                    InputStream response = connection.getErrorStream();

                    String errorMessage = null;

                    if ("SOAP".equals(_request.getType())) {

                        String responseXML = Strings.getString(response);

                        errorMessage = XML.getElementValue(responseXML, "faultcode");

                    }

                    if (errorMessage == null) {

                        BufferedReader rd = new BufferedReader(new InputStreamReader(response));

                        errorMessage = rd.readLine();

                        rd.close();

                    }

                    // log the error
                    _logger.error(errorMessage);

                    // only if there is no application cache show the error, otherwise it sends an empty response
                    if (actionCache == null) {

                        throw new JSONException(
                                " response code " + responseCode + " from server : " + errorMessage);

                    } else {

                        _logger.debug("Error not shown to user due to cache : " + errorMessage);

                    }

                }

                connection.disconnect();

            } // request url != null

        } // jsonData == null

    } // got app and page

    // if the jsonData is still null make an empty one
    if (jsonData == null)
        jsonData = new JSONObject();

    // add the sequence
    jsonData.put("sequence", sequence);

    // return the object
    return jsonData;

}

From source file:be.fedict.eid.idp.sp.protocol.ws_federation.AuthenticationRequestServlet.java

/**
 * {@inheritDoc}/*from   www . j  a  va  2 s  .  c  o m*/
 */
@SuppressWarnings("unchecked")
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    LOG.debug("doGet");

    String idpDestination;
    String spDestination;
    String context;
    String language;
    String spRealm;

    AuthenticationRequestService service = this.authenticationRequestServiceLocator.locateService();
    if (null != service) {
        idpDestination = service.getIdPDestination();
        context = service.getContext(request.getParameterMap());
        spDestination = service.getSPDestination();
        language = service.getLanguage();
        spRealm = service.getSPRealm();
    } else {
        idpDestination = this.idpDestination;
        context = null;
        if (null != this.spDestination) {
            spDestination = this.spDestination;
        } else {
            spDestination = request.getScheme() + "://" + request.getServerName() + ":"
                    + request.getServerPort() + request.getContextPath() + this.spDestinationPage;
        }
        language = this.language;
        spRealm = this.spRealm;
    }

    String targetUrl;
    if (null == spRealm) {
        targetUrl = idpDestination + "?wa=wsignin1.0" + "&wtrealm=" + spDestination;
    } else {
        targetUrl = idpDestination + "?wa=wsignin1.0" + "&wtrealm=" + spRealm + "&wreply=" + spDestination;
    }

    if (null != language && !language.trim().isEmpty()) {
        targetUrl += "&language=" + language;
    }
    if (null != context && !context.trim().isEmpty()) {
        targetUrl += "&wctx=" + context;
    }

    LOG.debug("targetURL: " + targetUrl);
    response.sendRedirect(targetUrl);

    // save state on session
    if (null == spRealm) {
        setRecipient(spDestination, request.getSession());
    } else {
        setRecipient(spRealm, request.getSession());
    }
    setContext(context, request.getSession());
}

From source file:com.redhat.rhn.frontend.servlets.DumpFilter.java

/** {@inheritDoc} */
public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain)
        throws IOException, ServletException {

    if (log.isDebugEnabled()) {
        // handle request
        HttpServletRequest request = (HttpServletRequest) req;
        log.debug("Entered doFilter() ===================================");
        log.debug("AuthType: " + request.getAuthType());
        log.debug("Method: " + request.getMethod());
        log.debug("PathInfo: " + request.getPathInfo());
        log.debug("Translated path: " + request.getPathTranslated());
        log.debug("ContextPath: " + request.getContextPath());
        log.debug("Query String: " + request.getQueryString());
        log.debug("Remote User: " + request.getRemoteUser());
        log.debug("Remote Host: " + request.getRemoteHost());
        log.debug("Remote Addr: " + request.getRemoteAddr());
        log.debug("SessionId: " + request.getRequestedSessionId());
        log.debug("uri: " + request.getRequestURI());
        log.debug("url: " + request.getRequestURL().toString());
        log.debug("Servlet path: " + request.getServletPath());
        log.debug("Server Name: " + request.getServerName());
        log.debug("Server Port: " + request.getServerPort());
        log.debug("RESPONSE encoding: " + resp.getCharacterEncoding());
        log.debug("REQUEST encoding: " + request.getCharacterEncoding());
        log.debug("JVM encoding: " + System.getProperty("file.encoding"));
        logSession(request.getSession());
        logHeaders(request);// ww  w. j  a  v  a  2 s.com
        logCookies(request.getCookies());
        logParameters(request);
        logAttributes(request);
        log.debug("Calling chain.doFilter() -----------------------------");
    }

    chain.doFilter(req, resp);

    if (log.isDebugEnabled()) {
        log.debug("Returned from chain.doFilter() -----------------------");
        log.debug("Handle Response, not much to print");
        log.debug("Response: " + resp.toString());
        log.debug("Leaving doFilter() ===================================");
    }
}

From source file:org.frontcache.FrontCacheEngine.java

/**
 * //from  ww  w.  j  a v  a  2 s.c o  m
 * @throws Exception
 */
public void processRequestInternal(RequestContext context) throws Exception {
    HttpServletRequest httpRequest = context.getRequest();
    String originRequestURL = getOriginUrl(context) + context.getRequestURI() + context.getRequestQueryString();
    logger.debug("originRequestURL: " + originRequestURL);

    boolean isSecure = ("https".equalsIgnoreCase(context.getFrontCacheProtocol())) ? true : false;
    String currentRequestBaseURL = makeURL(isSecure, context.getFrontCacheHost(),
            "" + httpRequest.getServerPort());
    logger.debug("currentRequestBaseURL: " + currentRequestBaseURL);

    boolean dynamicRequest = ("true".equals(httpRequest.getHeader(FCHeaders.X_FRONTCACHE_DYNAMIC_REQUEST)))
            ? true
            : false;

    if (!dynamicRequest && context.isCacheableRequest()
            && !ignoreCache(context.getRequestURI(), context.getDomainContext().getDomain())) // GET method without jsessionid
    {
        long start = System.currentTimeMillis();

        Map<String, List<String>> requestHeaders = FCUtils.buildRequestHeaders(httpRequest);
        getCurrentRequestURL2Context(context);

        WebResponse webResponse = null;
        try {
            webResponse = cacheProcessor.processRequest(originRequestURL, requestHeaders, httpClient, context);
        } catch (FrontCacheException fce) {
            // content/response is not cacheable (e.g. response type is not text) 
            fce.printStackTrace();
        }

        if (null != webResponse) {
            // include processor
            // don't process includes if request from Frontcache (e.g. Browser -> FC -> [FC] -> Origin)
            if (!context.getRequestFromFrontcache() && null != webResponse.getContent()) {
                // check process includes with recursion (resolve includes up to deepest level defined in includeProcessor)
                int recursionLevel = 0;
                while (includeProcessor.hasIncludes(webResponse, recursionLevel++)) {
                    // include processor return new webResponse with processed includes and merged headers
                    WebResponse incWebResponse = includeProcessor.processIncludes(webResponse,
                            currentRequestBaseURL, requestHeaders, httpClient, context, recursionLevel);

                    // copy content only (cache setting use this (parent), headers are merged inside IncludeProcessor )
                    webResponse.setContent(incWebResponse.getContent());
                }
            }

            if (INCLUDE_LEVEL_TOP_LEVEL.equals(context.getIncludeLevel())) {
                RequestLogger.logRequestToHeader(
                        currentRequestBaseURL + context.getRequestURI() + context.getRequestQueryString(),
                        context.getRequestType(), context.isToplevelCached(), // isCached 
                        false, // soft refresh
                        System.currentTimeMillis() - start, webResponse.getContentLenth(), // lengthBytes 
                        context, INCLUDE_LEVEL_TOP_LEVEL); // includeLevel
            }

            addResponseHeaders(webResponse, context);
            writeResponse(webResponse, context);

            if (null != context.getHttpClientResponse())
                context.getHttpClientResponse().close();

            return;
        }

    }

    // do dynamic call to origin (all methods except GET + listed in ignore list)
    {
        long start = System.currentTimeMillis();
        boolean isRequestCacheable = false;
        boolean isCached = false;
        long lengthBytes = -1; // TODO: set/get content length from context or just keep -1 ?

        //         forwardToOrigin();      
        new FC_BypassCache(httpClient, context).execute();

        RequestLogger.logRequest(originRequestURL, isRequestCacheable, isCached,
                System.currentTimeMillis() - start, lengthBytes, context);
        addResponseHeaders(context);
        writeResponse(context);
        if (null != context.getHttpClientResponse())
            context.getHttpClientResponse().close();
    }
    return;
}

From source file:com.icb123.Controller.ManageController.java

@RequestMapping(value = "/forJsp")
public String forJsp(HttpServletRequest request, HttpServletResponse response) throws Exception {
    try {//from w  ww  .j av  a 2  s  .c om
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
        Constants.root = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
                + request.getContextPath();
        String sysRootPath = request.getSession().getServletContext().getRealPath("\\");
        SystemStaticArgsSet.setSysRootPath(sysRootPath);
        String requestType = request.getParameter("requestType") == null ? ""
                : request.getParameter("requestType");
        int pageSize = 10;
        Employee emp = (Employee) request.getSession().getAttribute("Employee");
        if ("1".equals(requestType)) {//session
            //System.out.println("requestType");
            request.getSession().removeAttribute("Employee");
            request.getSession().removeAttribute("code");
            return "/pcManager/index.html";
        } else if ("2".equals(requestType)) {//?
            String nam1 = request.getParameter("num1") == null ? "" : request.getParameter("num1");
            String code = request.getParameter("code") == null ? "" : request.getParameter("code");
            int rowCount = employeeManager.countEmployee();
            int num = Integer.parseInt(nam1);
            Page page = new Page(pageSize, num, rowCount);
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("startRow", page.getStartRow());
            map.put("pageSize", pageSize);
            map.put("code", code);
            List<LinkedHashMap<String, String>> list = employeeManager.selectAllEmployee(map);
            request.setAttribute("list", list);
            request.setAttribute("page", page);
            request.setAttribute("code", code);
            return "/pcManager/jsp/Employee/listUser.jsp";
        } else if ("3".equals(requestType)) {// ?id
            String code = request.getParameter("id") == null ? "" : request.getParameter("id");
            int num1 = employeeManager.deleteEmployeeByCode(code);
            if (num1 > 0) {
                System.out.println(num1);
                request.setAttribute("ok", "?!!!");
            }
            return "manage/forJsp.do?pageSize1=4&num1=1&requestType=2";
        } else if ("4".equals(requestType)) {//?
            String id = request.getParameter("id") == null ? "" : request.getParameter("id");
            String name = request.getParameter("name1") == null ? "" : request.getParameter("name1");
            String weixinCode = request.getParameter("weixinCode") == null ? ""
                    : request.getParameter("weixinCode");
            String mobile = request.getParameter("mobile") == null ? "" : request.getParameter("mobile");
            String loginName = request.getParameter("loginName") == null ? ""
                    : request.getParameter("loginName");
            String positionCode = request.getParameter("positionCode") == null ? ""
                    : request.getParameter("positionCode");
            String departmentCode = request.getParameter("departmentCode") == null ? ""
                    : request.getParameter("departmentCode");
            String password = request.getParameter("password") == null ? "" : request.getParameter("password");
            String roleCode = request.getParameter("roleCode") == null ? "" : request.getParameter("roleCode");
            int id1 = Integer.parseInt(id);
            if (id1 != 0) {
                String modifiedCode = (String) request.getSession().getAttribute("code");
                Employee e = employeeManager.findEmployeeById(id1);
                String employeeCodeString = e.getCode();
                List<EmployeeRole> list = employeeManager.findRoleByCode(employeeCodeString);
                if (list.size() != 0) {
                    for (int i = 0; i < list.size(); i++) {
                        String RoleCode1 = list.get(i).getRoleCode();
                        if (!RoleCode1.equals(roleCode)) {
                            employeeManager.updateEmployeeRole(e.getCode(), roleCode);
                            int num = employeeManager.updateIcbEmployeeById(name, departmentCode, positionCode,
                                    loginName, password, id1, mobile, weixinCode, modifiedCode);
                            if (num != 0) {
                                request.setAttribute("ok", "?");
                            }
                        } else {
                            int num = employeeManager.updateIcbEmployeeById(name, departmentCode, positionCode,
                                    loginName, password, id1, mobile, weixinCode, modifiedCode);
                            if (num != 0) {
                                request.setAttribute("ok", "?");
                            }
                        }
                    }
                } else {
                    employeeManager.saveEmployeeRole(e.getCode(), roleCode);
                    int num = employeeManager.updateIcbEmployeeById(name, departmentCode, positionCode,
                            loginName, password, id1, mobile, weixinCode, modifiedCode);
                    if (num != 0) {
                        request.setAttribute("ok", "?");
                    }
                }
            } else {
                String code = systemParamManager.employeeCode();
                employeeManager.saveEmployee(name, mobile, loginName, password, positionCode, departmentCode,
                        code, emp.getCode(), weixinCode);
                employeeManager.saveEmployeeRole(code, roleCode);
                request.setAttribute("ok", "?");
            }
            return "manage/forJsp.do?requestType=2&num1=1";
        } else if ("5".equals(requestType)) {//?
            String nam1 = request.getParameter("num1") == null ? "" : request.getParameter("num1");
            String name = request.getParameter("name1") == null ? "" : request.getParameter("name1");
            String mobile = request.getParameter("mobile1") == null ? "" : request.getParameter("mobile1");
            List<Map<String, String>> list1 = new ArrayList<Map<String, String>>();
            if (name == "" && mobile == "") {
                int rowCount = customerManager.countCustomer();
                int num = Integer.parseInt(nam1);
                Page page = new Page(pageSize, num, rowCount);
                Map<String, Object> map = new HashMap<String, Object>();
                map.put("startRow", page.getStartRow());
                map.put("pageSize", pageSize);
                list1 = customerManager.selectAllCustomer(map);
                request.setAttribute("list1", list1);
                request.setAttribute("page", page);
                return "/pcManager/jsp/customer/listCustomer.jsp";
            } else {
                Map<String, Object> map1 = new HashMap<String, Object>();
                map1.put("name", name);
                map1.put("mobile", mobile);
                int rowCount = customerManager.countByNameOrmobile(map1);
                int num = Integer.parseInt(nam1);
                Page page = new Page(pageSize, num, rowCount);
                Map<String, Object> map = new HashMap<String, Object>();
                map.put("name", name);
                map.put("mobile", mobile);
                map.put("startRow", page.getStartRow());
                map.put("pageSize", pageSize);
                list1 = customerManager.findByNameOrmobile(map);
                request.setAttribute("list1", list1);
                request.setAttribute("page", page);
                request.setAttribute("mobile", mobile);
                request.setAttribute("name", name);
                return "/pcManager/jsp/customer/listCustomer.jsp";
            }
        } else if ("6".equals(requestType)) {//? 2015/11/11 ?
            return "/pcManager/jsp/car/listCar.jsp";
        } else if ("7".equals(requestType)) {//??? 2015/11/11 ?
            String typeCode = "";
            String nam1 = request.getParameter("num1") == null ? "" : request.getParameter("num1");
            typeCode = request.getParameter("code") == null ? "" : request.getParameter("code");
            List<AccessoriesType> typeList = accessoriesTypeManager.selectAll();
            int num = Integer.parseInt(nam1);
            if (typeCode == "") {
                Map<String, Object> map = new HashMap<String, Object>();
                int rowCount = accessoriesInfoManager.countAccessoriesStorage();
                Page page = new Page(pageSize, num, rowCount);
                map.put("startRow", page.getStartRow());
                map.put("pageSize", pageSize);
                List<AccessoriesStorage> list = accessoriesInfoManager.searchAccessoriesStorage(map);
                request.setAttribute("list", list);
                request.setAttribute("page", page);
                request.setAttribute("typeCode", typeCode);
                request.setAttribute("typeList", typeList);
                return "/pcManager/jsp/accessories/listAccessories.jsp";
            } else {
                Map<String, Object> map = new HashMap<String, Object>();
                int rowCount = accessoriesInfoManager.countByTypeCode(typeCode);
                Page page = new Page(pageSize, num, rowCount);
                map.put("startRow", page.getStartRow());
                map.put("pageSize", pageSize);
                map.put("typeCode", typeCode);
                List<AccessoriesStorage> list = accessoriesInfoManager.searchByTypeCode(map);
                request.setAttribute("list", list);
                request.setAttribute("typeList", typeList);
                request.setAttribute("page", page);
                request.setAttribute("typeCode", typeCode);
                return "/pcManager/jsp/accessories/listAccessories.jsp";
            }
        } else if ("8".equals(requestType)) {//? 2015/11/11 ?
            List<FalseAccount> list = falseAccountManager.selectAllFalseAccount();
            request.setAttribute("list", list);
            return "/pcManager/jsp/customer/addAccount.jsp";
        } else if ("9".equals(requestType)) {//? 2015/11/11 ?
            List<Role> list = employeeManager.findAllRole();
            request.setAttribute("list", list);
            return "/pcManager/jsp/Role/listRole.jsp";
        } else if ("10".equals(requestType)) {// 2015/11/12 ?
            String nam1 = request.getParameter("num1") == null ? "" : request.getParameter("num1");
            String name = request.getParameter("name1") == null ? "" : request.getParameter("name1");
            String licensePlate = request.getParameter("licensePlate1") == null ? ""
                    : request.getParameter("licensePlate1");
            if (name == "" && licensePlate == "") {
                int num = Integer.parseInt(nam1);
                int rowCount = customerManager.countCustomerCar();
                Page page = new Page(pageSize, num, rowCount);
                Map<String, Object> map = new HashMap<String, Object>();
                map.put("startRow", page.getStartRow());
                map.put("pageSize", pageSize);
                List<Map<String, Object>> list = customerManager.selectCustomerCar(map);
                request.setAttribute("list", list);
                request.setAttribute("page", page);
                return "/pcManager/jsp/customer/customerCar.jsp";
            } else {
                Map<String, Object> map = new HashMap<String, Object>();
                map.put("name", name);
                map.put("licensePlate", licensePlate);
                int rowCount = customerManager.countByNameOrlicensePlate(map);
                int num = Integer.parseInt(nam1);
                System.out.println(rowCount);
                Page page = new Page(pageSize, num, rowCount);
                Map<String, Object> map1 = new HashMap<String, Object>();
                map1.put("name", name);
                map1.put("licensePlate", licensePlate);
                map1.put("startRow", page.getStartRow());
                map1.put("pageSize", pageSize);
                List<Map<String, Object>> list = customerManager.selectByNameOrlicensePlate(map1);
                request.setAttribute("list", list);
                request.setAttribute("page", page);
                request.setAttribute("name", name);
                request.setAttribute("licensePlate", licensePlate);
                return "/pcManager/jsp/customer/customerCar.jsp";
            }
        }
    } catch (Exception e) {
        outPutErrorInfor(ManageController.class.getName(), "forJsp", e);
        e.printStackTrace();
    }
    return null;
}

From source file:edu.gmu.csiss.automation.pacs.servlet.FileUploadServlet.java

/**
 * Processes requests for both HTTP//from   ww  w  .  j  ava  2s  . c  o m
 * <code>GET</code> and
 * <code>POST</code> methods.
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest req, HttpServletResponse res)
        throws ServletException, IOException {
    res.setContentType("text/plain;charset=gbk");

    res.setContentType("text/html; charset=utf-8");
    PrintWriter pw = res.getWriter();
    try {
        //initialize the prefix url
        if (prefix_url == null) {
            //                String hostname = req.getServerName ();
            //                int port = req.getServerPort ();
            //                prefix_url = "http://"+hostname+":"+port+"/igfds/"+relativePath+"/";
            //updated by Ziheng - on 8/27/2015
            //This method should be used everywhere.
            int num = req.getRequestURI().indexOf("/PACS");
            String prefix = req.getRequestURI().substring(0, num + "/PACS".length()); //in case there is something before PACS
            prefix_url = req.getScheme() + "://" + req.getServerName()
                    + ("http".equals(req.getScheme()) && req.getServerPort() == 80
                            || "https".equals(req.getScheme()) && req.getServerPort() == 443 ? ""
                                    : ":" + req.getServerPort())
                    + prefix + "/" + relativePath + "/";
        }
        pw.println("<!DOCTYPE html>");
        pw.println("<html>");
        String head = "<head>" + "<title>File Uploading Response</title>"
                + "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">"
                + "<script type=\"text/javascript\" src=\"js/TaskGridTool.js\"></script>" + "</head>";
        pw.println(head);
        pw.println("<body>");

        DiskFileItemFactory diskFactory = new DiskFileItemFactory();
        // threshold  2M 
        //extend to 2M - updated by ziheng - 9/25/2014
        diskFactory.setSizeThreshold(2 * 1024);
        // repository 
        diskFactory.setRepository(new File(tempPath));

        ServletFileUpload upload = new ServletFileUpload(diskFactory);
        // 2M
        upload.setSizeMax(2 * 1024 * 1024);
        // HTTP
        List fileItems = upload.parseRequest(req);
        Iterator iter = fileItems.iterator();
        while (iter.hasNext()) {
            FileItem item = (FileItem) iter.next();
            if (item.isFormField()) {
                processFormField(item, pw);
            } else {
                processUploadFile(item, pw);
            }
        } // end while()
          //add some buttons for further process
        pw.println("<input type=\"button\" id=\"bt\" value=\"load\" onclick=\"load();\">");
        pw.println("<input type=\"button\" id=\"close\" value=\"close window\" onclick=\"window.close();\">");
        pw.println("</body>");
        pw.println("</html>");
    } catch (Exception e) {
        e.printStackTrace();
        pw.println("ERR:" + e.getClass().getName() + ":" + e.getLocalizedMessage());
    } finally {
        pw.flush();
        pw.close();
    }
}

From source file:org.daxplore.presenter.server.servlets.PresenterServlet.java

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) {
    PersistenceManager pm = null;//w  w  w .j  a v  a2 s  .  c  om
    try {
        // Get input from URL
        //TODO use better and more stable parsing
        String prefix = request.getPathInfo();
        if (prefix != null && !prefix.isEmpty()) {
            if (prefix.charAt(0) == '/') {
                prefix = prefix.substring(1);
            }
            if (!prefix.isEmpty() && prefix.charAt(prefix.length() - 1) == '/') {
                prefix = prefix.substring(0, prefix.length() - 2);
            }
        }
        String useragent = request.getHeader("user-agent");
        Cookie[] cookies = request.getCookies();
        String feature = request.getParameter("f");
        String baseurl = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort();

        // Clean user input
        if (prefix == null || !SharedResourceTools.isSyntacticallyValidPrefix(prefix)) {
            throw new BadRequestException(
                    "Someone tried to access a syntactically invalid prefix: '" + prefix + "'");
        }

        boolean browserSupported = true;
        double ieversion = ServerTools.getInternetExplorerVersion(useragent);
        if (useragent == null | (ieversion > 0.0 & ieversion < 8.0)) {
            browserSupported = false;
        }

        boolean ignoreBadBrowser = false;
        if (cookies != null) {
            ignoreBadBrowser = ServerTools.ignoreBadBrowser(cookies);
        }
        browserSupported |= ignoreBadBrowser;

        pm = PMF.get().getPersistenceManager();
        String googleAnalyticsID = SettingItemStore.getProperty(pm, prefix, "adminpanel", "gaID");
        String gaTemplate = "";
        if (googleAnalyticsID != null && !googleAnalyticsID.equals("")) {
            if (googleAnalyticsTrackingTemplate == null) {
                try {
                    googleAnalyticsTrackingTemplate = IOUtils
                            .toString(getServletContext().getResourceAsStream("/js/ga-tracking.js"));
                } catch (IOException e) {
                    throw new InternalServerException("Failed to load the google analytics tracking template",
                            e);
                }
            }
            gaTemplate = MessageFormat.format(googleAnalyticsTrackingTemplate, googleAnalyticsID);
        }

        String responseHTML = "";
        if (!browserSupported) {
            responseHTML = getUnsupportedBrowserHTML(baseurl, gaTemplate);
        } else {
            Locale locale = ServerTools.selectLocale(request, prefix);

            String secondaryFlagText = SettingItemStore.getLocalizedProperty(pm, prefix, "properties/usertexts",
                    locale, "secondary_flag");
            //TODO handle timepoints properly
            String timepoint0Text = SettingItemStore.getLocalizedProperty(pm, prefix, "properties/usertexts",
                    locale, "timepoint_0");
            String timepoint1Text = SettingItemStore.getLocalizedProperty(pm, prefix, "properties/usertexts",
                    locale, "timepoint_1");
            String pageTitle = SettingItemStore.getLocalizedProperty(pm, prefix, "properties/usertexts", locale,
                    "page_title");
            ServerPrefixProperties prefixProperties = new ServerPrefixProperties(prefix, secondaryFlagText,
                    timepoint0Text, timepoint1Text, pageTitle);

            if (feature != null && feature.equalsIgnoreCase("embed")) { // embedded chart

                // TODO clean query string
                String queryString = request.getParameter("q");
                responseHTML = getEmbedHTML(pm, prefix, locale, queryString, baseurl, prefixProperties,
                        gaTemplate);

            } else if (feature != null && feature.equalsIgnoreCase("print")) { // printer-friendly chart

                String serverPath = request.getRequestURL().toString();
                // remove last slash
                if (serverPath.charAt(serverPath.length() - 1) == '/') {
                    serverPath = serverPath.substring(0, serverPath.length() - 1);
                }
                // remove module name
                serverPath = serverPath.substring(0, serverPath.lastIndexOf("/"));

                // TODO clean query string
                String queryString = request.getParameter("q");
                responseHTML = getPrintHTML(pm, prefix, locale, serverPath, queryString, baseurl, gaTemplate);

            } else { // standard presenter

                responseHTML = getPresenterHTML(pm, prefix, locale, baseurl, prefixProperties, gaTemplate);

            }
        }

        response.setContentType("text/html; charset=UTF-8");
        try (Writer writer = response.getWriter()) {
            writer.write(responseHTML);
        } catch (IOException e) {
            throw new InternalServerException("Failed to display presenter servlet", e);
        }
    } catch (BadRequestException e) {
        logger.log(Level.WARNING, e.getMessage(), e);
        response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
    } catch (InternalServerException e) {
        logger.log(Level.SEVERE, e.getMessage(), e);
        response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    } catch (RuntimeException e) {
        logger.log(Level.SEVERE, "Unexpected exception: " + e.getMessage(), e);
        response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    } finally {
        if (pm != null) {
            pm.close();
        }
    }
}

From source file:gov.nih.nci.security.upt.actions.LoginAction.java

public String execute() {
    HttpServletRequest request = ServletActionContext.getRequest();

    AuthenticationManager authenticationManager = null;
    AuthorizationManager authorizationManager = null;
    UserProvisioningManager userProvisioningManager = null;
    boolean loginSuccessful = false;
    boolean hasPermission = false;
    String uptContextName = DisplayConstants.UPT_CONTEXT_NAME;
    Application application = null;/*from w w  w  .  ja v a2 s.com*/

    String serverInfoPathPort = (request.isSecure() ? "https://" : "http://") + request.getServerName() + ":"
            + request.getServerPort();
    ObjectFactory.initialize("upt-beans.xml");
    UPTProperties uptProperties = null;
    String urlContextForLoginApp = "";
    String centralUPTConfiguration = "";
    try {
        uptProperties = (UPTProperties) ObjectFactory.getObject("UPTProperties");
        urlContextForLoginApp = uptProperties.getBackwardsCompatibilityInformation()
                .getLoginApplicationContextName();
        if (!StringUtils.isBlank(urlContextForLoginApp)) {
            serverInfoPathPort = serverInfoPathPort + "/" + urlContextForLoginApp + "/";
        } else {
            serverInfoPathPort = serverInfoPathPort + "/" + DisplayConstants.LOGIN_APPLICATION_CONTEXT_NAME
                    + "/";
        }
        uptContextName = DisplayConstants.UPT_AUTHENTICATION_CONTEXT_NAME;
    } catch (UPTConfigurationException e) {
        serverInfoPathPort = serverInfoPathPort + "/" + DisplayConstants.LOGIN_APPLICATION_CONTEXT_NAME + "/";

    }

    if (loginForm == null) {
        loginForm = new LoginForm();
        loginForm.setApplicationContextName(applicationContextName);
        loginForm.setLoginId(loginId);
        loginForm.setPassword(password);
    }

    if (StringUtils.isBlank(loginForm.getApplicationContextName())
            || StringUtils.isBlank(loginForm.getLoginId()) || StringUtils.isBlank(loginForm.getPassword())) {

        redirectAction = serverInfoPathPort;
        return "redirect";
    }

    UserInfoHelper.setUserInfo(loginForm.getLoginId(), request.getSession().getId());
    clearActionErrors();

    try {
        authorizationManager = SecurityServiceProvider.getAuthorizationManager(uptContextName);
        if (null == authorizationManager) {
            addActionError(
                    "Unable to initialize Authorization Manager for the given application context using new configuration");
            if (log.isDebugEnabled())
                log.debug("|" + loginForm.getLoginId()
                        + "||Login|Failure|Unable to instantiate Authorization Manager for UPT application using new configuration||");
            return ForwardConstants.LOGIN_FAILURE;
        }
    } catch (CSException cse) {

        authorizationManager = null;
    }

    if (null == authorizationManager) {

        try {

            if (null == uptContextName || uptContextName.equalsIgnoreCase("")) {
                addActionError("Unable to read the UPT Context Name from Security Config File");
                if (log.isDebugEnabled())
                    log.debug("|" + loginForm.getLoginId()
                            + "||Login|Failure|Unable to read the UPT Context Name from Security Config File");
                return ForwardConstants.LOGIN_FAILURE;
            }
        } catch (Exception ex) {
            addActionError(org.apache.commons.lang.StringEscapeUtils.escapeHtml(ex.getMessage()));
            if (log.isDebugEnabled())
                log.debug("|" + loginForm.getLoginId()
                        + "||Login|Failure|Unable to read the UPT Context Name from Security Config File||");
            return ForwardConstants.LOGIN_FAILURE;
        }
    }
    try {

        authenticationManager = SecurityServiceProvider
                .getAuthenticationManager(DisplayConstants.UPT_AUTHENTICATION_CONTEXT_NAME);
        if (null == authenticationManager) {
            addActionError("Unable to initialize Authentication Manager for the given application context");
            if (log.isDebugEnabled())
                log.debug("|" + loginForm.getLoginId()
                        + "||Login|Failure|Unable to instantiate AuthenticationManager for UPT application||");
            return ForwardConstants.LOGIN_FAILURE;
        }
    } catch (CSException cse) {
        addActionError(org.apache.commons.lang.StringEscapeUtils.escapeHtml(cse.getMessage()));
        if (log.isDebugEnabled())
            log.debug("|" + loginForm.getLoginId()
                    + "||Login|Failure|Unable to instantiate AuthenticationManager for UPT application|"
                    + loginForm.toString() + "|" + cse.getMessage());
        return ForwardConstants.LOGIN_FAILURE;
    }
    try {
        loginSuccessful = authenticationManager.login(loginForm.getLoginId(), loginForm.getPassword());
    } catch (CSCredentialExpiredException cse) {
        addActionError(org.apache.commons.lang.StringEscapeUtils.escapeHtml(cse.getMessage()));
        if (log.isDebugEnabled())
            log.debug("|" + loginForm.getLoginId() + "||Login|Failure|Password Expired for user name "
                    + loginForm.getLoginId() + " and" + loginForm.getApplicationContextName() + " application|"
                    + loginForm.toString() + "|" + cse.getMessage());
        return ForwardConstants.EXPIRED_PASSWORD;
    } catch (CSFirstTimeLoginException cse) {
        addActionError(org.apache.commons.lang.StringEscapeUtils.escapeHtml(cse.getMessage()));
        if (log.isDebugEnabled())
            log.debug("|" + loginForm.getLoginId() + "||Login|Failure|Password Expired for user name "
                    + loginForm.getLoginId() + " and" + loginForm.getApplicationContextName() + " application|"
                    + loginForm.toString() + "|" + cse.getMessage());
        return ForwardConstants.EXPIRED_PASSWORD;
    } catch (CSException cse) {
        addActionError(org.apache.commons.lang.StringEscapeUtils.escapeHtml(cse.getMessage()));
        if (log.isDebugEnabled())
            log.debug("|" + loginForm.getLoginId() + "||Login|Failure|Login Failed for user name "
                    + loginForm.getLoginId() + " and" + loginForm.getApplicationContextName() + " application|"
                    + loginForm.toString() + "|" + cse.getMessage());
        return ForwardConstants.LOGIN_FAILURE;
    }

    try {
        authorizationManager = SecurityServiceProvider.getAuthorizationManager(uptContextName);
        if (null == authorizationManager) {
            addActionError("Unable to initialize Authorization Manager for the given application context");
            if (log.isDebugEnabled())
                log.debug("|" + loginForm.getLoginId()
                        + "||Login|Failure|Unable to instantiate Authorization Manager for UPT application||");
            return ForwardConstants.LOGIN_FAILURE;
        }
    } catch (CSException cse) {
        addActionError(org.apache.commons.lang.StringEscapeUtils.escapeHtml(cse.getMessage()));
        if (log.isDebugEnabled())
            log.debug("|" + loginForm.getLoginId()
                    + "||Login|Failure|Unable to instantiate AuthorizationManager for UPT application|"
                    + loginForm.toString() + "|" + cse.getMessage());
        return ForwardConstants.LOGIN_FAILURE;
    }
    try {
        hasPermission = authorizationManager.checkPermission(loginForm.getLoginId(),
                loginForm.getApplicationContextName(), null);
        if (!hasPermission) {
            try {
                userProvisioningManager = getUserProvisioningManager(authorizationManager,
                        loginForm.getApplicationContextName());
                if (null == userProvisioningManager) {
                    addActionError(
                            "Unable to initialize Authorization Manager for the given application context");
                    if (log.isDebugEnabled())
                        log.debug("|" + loginForm.getLoginId()
                                + "||Login|Failure|Unable to instantiate User Provisioning Manager for "
                                + loginForm.getApplicationContextName() + " application||");
                    return ForwardConstants.LOGIN_FAILURE;
                }
            } catch (CSException cse) {
                addActionError(org.apache.commons.lang.StringEscapeUtils.escapeHtml(cse.getMessage()));
                if (log.isDebugEnabled())
                    log.debug("|" + loginForm.getLoginId()
                            + "||Login|Failure|Unable to instantiate User Provisioning Manager for |"
                            + loginForm.toString() + "|" + cse.getMessage());
                return ForwardConstants.LOGIN_FAILURE;
            }
            sessionMap.put(DisplayConstants.USER_PROVISIONING_MANAGER, userProvisioningManager);
            sessionMap.put(DisplayConstants.LOGIN_OBJECT, loginForm);
            sessionMap.put(DisplayConstants.CURRENT_TABLE_ID, DisplayConstants.HOME_ID);

            sessionMap.put(Constants.UPT_USER_OPERATION + "_" + Constants.CSM_ACCESS_PRIVILEGE, "false");
            sessionMap.put(Constants.UPT_PROTECTION_ELEMENT_OPERATION + "_" + Constants.CSM_ACCESS_PRIVILEGE,
                    "false");
            sessionMap.put(Constants.UPT_PRIVILEGE_OPERATION + "_" + Constants.CSM_ACCESS_PRIVILEGE, "false");
            sessionMap.put(Constants.UPT_GROUP_OPERATION + "_" + Constants.CSM_ACCESS_PRIVILEGE, "false");
            sessionMap.put(Constants.UPT_PROTECTION_GROUP_OPERATION + "_" + Constants.CSM_ACCESS_PRIVILEGE,
                    "false");
            sessionMap.put(Constants.UPT_ROLE_OPERATION + "_" + Constants.CSM_ACCESS_PRIVILEGE, "false");
            sessionMap.put(Constants.UPT_INSTANCE_LEVEL_OPERATION + "_" + Constants.CSM_ACCESS_PRIVILEGE,
                    "false");

            return ForwardConstants.LOGIN_SUCCESS;
        }
    } catch (CSException cse) {
        addActionError(org.apache.commons.lang.StringEscapeUtils.escapeHtml(cse.getMessage()));
        if (log.isDebugEnabled())
            log.debug("|" + loginForm.getLoginId() + "||Login|Failure|Error in checking permission|"
                    + loginForm.toString() + "|" + cse.getMessage());
        return ForwardConstants.LOGIN_FAILURE;
    }

    try {
        //UserProvisioningManager upm = (UserProvisioningManager)authorizationManager;
        application = authorizationManager.getApplication(loginForm.getApplicationContextName());
        userProvisioningManager = getUserProvisioningManager(authorizationManager,
                loginForm.getApplicationContextName());
        if (null == userProvisioningManager) {
            addActionError("Unable to initialize Authorization Manager for the given application context");
            if (log.isDebugEnabled())
                log.debug("|" + loginForm.getLoginId()
                        + "||Login|Failure|Unable to instantiate User Provisioning Manager for "
                        + loginForm.getApplicationContextName() + " application||");
            return ForwardConstants.LOGIN_FAILURE;
        }
    } catch (CSException cse) {
        addActionError(org.apache.commons.lang.StringEscapeUtils.escapeHtml(cse.getMessage()));
        if (log.isDebugEnabled())
            log.debug("|" + loginForm.getLoginId()
                    + "||Login|Failure|Unable to instantiate User Provisioning Manager for |"
                    + loginForm.toString() + "|" + cse.getMessage());
        return ForwardConstants.LOGIN_FAILURE;
    }

    sessionMap.put(DisplayConstants.USER_PROVISIONING_MANAGER, userProvisioningManager);
    sessionMap.put(DisplayConstants.LOGIN_OBJECT, loginForm);
    sessionMap.put(DisplayConstants.CURRENT_TABLE_ID, DisplayConstants.HOME_ID);

    authenticationManager = null;
    authorizationManager = null;

    try {
        processUptOperation(userProvisioningManager, loginForm.getLoginId(), application.getApplicationName());
    } catch (CSTransactionException e) {
        addActionError(org.apache.commons.lang.StringEscapeUtils.escapeHtml(e.getMessage()));
        if (log.isDebugEnabled())
            log.debug("|" + loginForm.getLoginId()
                    + "||Login|Failure|Unable to check permissions for the user operations |"
                    + loginForm.toString() + "|" + e.getMessage());
        return ForwardConstants.LOGIN_FAILURE;
    }

    if (loginForm.getApplicationContextName().equalsIgnoreCase(uptContextName)) {
        sessionMap.put(DisplayConstants.ADMIN_USER, DisplayConstants.ADMIN_USER);
        if (log.isDebugEnabled())
            log.debug(request.getSession().getId() + "|"
                    + ((LoginForm) sessionMap.get(DisplayConstants.LOGIN_OBJECT)).getLoginId()
                    + "||Login|Success|Login Successful for user " + loginForm.getLoginId() + " and "
                    + loginForm.getApplicationContextName()
                    + " application, Forwarding to the Super Admin Home Page||");
        return ForwardConstants.ADMIN_LOGIN_SUCCESS;
    } else {
        if (log.isDebugEnabled())
            log.debug(request.getSession().getId() + "|"
                    + ((LoginForm) sessionMap.get(DisplayConstants.LOGIN_OBJECT)).getLoginId()
                    + "||Login|Success|Login Successful for user " + loginForm.getLoginId() + " and "
                    + loginForm.getApplicationContextName() + " application, Forwarding to the Home Page||");
        return ForwardConstants.LOGIN_SUCCESS;
    }
}