Example usage for javax.servlet.http HttpSession getAttributeNames

List of usage examples for javax.servlet.http HttpSession getAttributeNames

Introduction

In this page you can find the example usage for javax.servlet.http HttpSession getAttributeNames.

Prototype

public Enumeration<String> getAttributeNames();

Source Link

Document

Returns an Enumeration of String objects containing the names of all the objects bound to this session.

Usage

From source file:com.hihsoft.baseclass.web.controller.BaseController.java

/**
 * Session//from   w  w  w  .j a v a2 s.  com
 * @param request
 * @author Xiaojf
 * @since 2011-8-31
 */
@SuppressWarnings("unchecked")
public void clearSession(HttpServletRequest request) {
    HttpSession session = request.getSession();
    Enumeration<String> attributeNames = session.getAttributeNames();
    while (attributeNames.hasMoreElements()) {
        session.removeAttribute(attributeNames.nextElement());
    }
}

From source file:com.cws.esolutions.security.filters.SSLEnforcementFilter.java

public void doFilter(final ServletRequest sRequest, final ServletResponse sResponse,
        final FilterChain filterChain) throws ServletException, IOException {
    final String methodName = SSLEnforcementFilter.CNAME
            + "#doFilter(final ServletRequest req, final servletResponse res, final FilterChain filterChain) throws ServletException, IOException";

    if (DEBUG) {/*w  w  w.j  a  va 2  s .  co  m*/
        DEBUGGER.debug(methodName);
        DEBUGGER.debug("ServletRequest: {}", sRequest);
        DEBUGGER.debug("ServletResponse: {}", sResponse);
        DEBUGGER.debug("FilterChain: {}", filterChain);
    }

    final HttpServletRequest hRequest = (HttpServletRequest) sRequest;
    final HttpServletResponse hResponse = (HttpServletResponse) sResponse;

    if (DEBUG) {
        final HttpSession hSession = hRequest.getSession();

        DEBUGGER.debug("HttpServletRequest: {}", hRequest);
        DEBUGGER.debug("HttpServletResponse: {}", hResponse);
        DEBUGGER.debug("HttpSession: {}", hSession);

        DEBUGGER.debug("Dumping session content:");
        Enumeration<?> sessionEnumeration = hSession.getAttributeNames();

        while (sessionEnumeration.hasMoreElements()) {
            String element = (String) sessionEnumeration.nextElement();
            Object value = hSession.getAttribute(element);

            DEBUGGER.debug("Attribute: {}; Value: {}", element, value);
        }

        DEBUGGER.debug("Dumping request content:");
        Enumeration<?> requestEnumeration = hRequest.getAttributeNames();

        while (requestEnumeration.hasMoreElements()) {
            String element = (String) requestEnumeration.nextElement();
            Object value = hRequest.getAttribute(element);

            DEBUGGER.debug("Attribute: {}; Value: {}", element, value);
        }

        DEBUGGER.debug("Dumping request parameters:");
        Enumeration<?> paramsEnumeration = hRequest.getParameterNames();

        while (paramsEnumeration.hasMoreElements()) {
            String element = (String) paramsEnumeration.nextElement();
            Object value = hRequest.getParameter(element);

            DEBUGGER.debug("Parameter: {}; Value: {}", element, value);
        }
    }

    if (SSLEnforcementFilter.LOCALHOST.contains(sRequest.getServerName())) {
        if (DEBUG) {
            DEBUGGER.debug("Local request. Breaking out...");
        }

        filterChain.doFilter(sRequest, sResponse);

        return;
    }

    if ((this.ignoreHosts != null) && (this.ignoreHosts.length != 0)) {
        if (Arrays.asList(this.ignoreHosts).contains("ALL")) {
            if (DEBUG) {
                DEBUGGER.debug("ALL URIs are ignored. Breaking ...");
            }

            filterChain.doFilter(sRequest, sResponse);

            return;
        }

        for (String host : this.ignoreHosts) {
            String requestHost = host.trim();

            if (DEBUG) {
                DEBUGGER.debug(host);
                DEBUGGER.debug(requestHost);
            }

            if (StringUtils.equals(requestHost, sRequest.getServerName().trim())) {
                if (DEBUG) {
                    DEBUGGER.debug("Host found in ignore list. Not processing request!");
                }

                filterChain.doFilter(sRequest, sResponse);

                return;
            }
        }
    }

    if ((this.ignoreURIs != null) && (this.ignoreURIs.length != 0)) {
        if (Arrays.asList(this.ignoreURIs).contains("ALL")) {
            if (DEBUG) {
                DEBUGGER.debug("ALL URIs are ignored. Breaking ...");
            }

            filterChain.doFilter(sRequest, sResponse);

            return;
        }

        // no hosts in ignore list
        for (String uri : this.ignoreURIs) {
            String requestURI = uri.trim();

            if (DEBUG) {
                DEBUGGER.debug(uri);
                DEBUGGER.debug(requestURI);
            }

            if (StringUtils.equals(requestURI, hRequest.getRequestURI().trim())) {
                if (DEBUG) {
                    DEBUGGER.debug("URI found in ignore list. Not processing request!");
                }

                filterChain.doFilter(sRequest, sResponse);

                return;
            }
        }
    }

    if (hRequest.isSecure()) {
        // Request came in on a secure channel or
        // the HTTP:DECRYPTED header is true
        // do nothing
        if (DEBUG) {
            DEBUGGER.debug("Filter not applied to request - already secured. No action taken.");
        }

        filterChain.doFilter(sRequest, sResponse);

        return;
    }

    // secure it
    StringBuilder redirectURL = new StringBuilder().append(SSLEnforcementFilter.SECURE_URL_PREFIX)
            .append(sRequest.getServerName())
            .append((sRequest.getServerPort() != SSLEnforcementFilter.SECURE_URL_PORT)
                    ? ":" + sRequest.getServerPort()
                    : null)
            .append(hRequest.getRequestURI());

    if (StringUtils.isNotBlank(hRequest.getQueryString())) {
        redirectURL.append("?" + hRequest.getQueryString());
    }

    if (DEBUG) {
        DEBUGGER.debug("redirectURL: {}", redirectURL);
    }

    hResponse.sendRedirect(URLEncoder.encode(redirectURL.toString(), systemConfig.getEncoding()));

    return;
}

From source file:freddo.dtalk2.broker.servlet.DTalkServerEndpoint.java

@OnOpen
public void onOpen(Session session, EndpointConfig config) {
    LOG.trace(">>> onOpen: {}, userProperties: {}", session.getId(), config.getUserProperties());

    mConfig = config;/*  w  ww  .ja v a2  s  . com*/
    mSession = session;

    if (LOG.isDebugEnabled()) {
        HandshakeRequest req = getHandshakeRequest();
        HttpSession httpSession = (HttpSession) req.getHttpSession();
        LOG.debug("=================================");
        LOG.debug("QueryString   : {}", req.getQueryString());
        LOG.debug("RequestURI    : {}", req.getRequestURI());
        LOG.debug("Headers       : {}", req.getHeaders());
        LOG.debug("UserPrincipal : {}", req.getUserPrincipal());
        LOG.debug("ParameterMap  : {}", req.getParameterMap());
        LOG.debug("=================================");
        if (httpSession != null) {
            Enumeration<String> e = httpSession.getAttributeNames();
            while (e.hasMoreElements()) {
                final String attr = e.nextElement();
                LOG.debug("Session[{}]: {}", attr, httpSession.getAttribute(attr));
            }
            LOG.debug("=================================");
        }
    }

    // TODO register connection & notify context listener

}

From source file:net.sourceforge.fenixedu.presentationTier.util.ExceptionInformation.java

private void sessionContextAppend(HttpServletRequest request, StringBuilder exceptionInfo) {

    Map<String, Object> sessionContext = new HashMap<String, Object>();
    HttpSession session = request.getSession(false);
    if (session != null) {
        Enumeration sessionContents = session.getAttributeNames();
        while (sessionContents.hasMoreElements()) {
            String sessionElement = sessionContents.nextElement().toString();
            sessionContext.put(sessionElement, session.getAttribute(sessionElement));
            exceptionInfo.append("Element:").append(sessionElement).append("\n");
            exceptionInfo.append("Element Value:").append(session.getAttribute(sessionElement)).append("\n");
        }/*from  www.jav  a2  s .  c o  m*/
    }
    this.sessionContextEntries = sessionContext;
}

From source file:com.cws.us.pws.controllers.AboutController.java

@RequestMapping(value = "/default", method = RequestMethod.GET)
public final ModelAndView showDefaultPage() {
    final String methodName = AboutController.CNAME + "#showDefaultPage()";

    if (DEBUG) {/*  w  w  w. j av  a 2  s  .c  o  m*/
        DEBUGGER.debug(methodName);
    }

    ModelAndView mView = new ModelAndView();

    final ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder
            .currentRequestAttributes();
    final HttpServletRequest hRequest = requestAttributes.getRequest();
    final HttpSession hSession = hRequest.getSession();

    if (DEBUG) {
        DEBUGGER.debug("ServletRequestAttributes: {}", requestAttributes);
        DEBUGGER.debug("HttpServletRequest: {}", hRequest);
        DEBUGGER.debug("HttpSession: {}", hSession);

        DEBUGGER.debug("Dumping session content:");
        @SuppressWarnings("unchecked")
        Enumeration<String> sessionEnumeration = hSession.getAttributeNames();

        while (sessionEnumeration.hasMoreElements()) {
            String sessionElement = sessionEnumeration.nextElement();
            Object sessionValue = hSession.getAttribute(sessionElement);

            DEBUGGER.debug("Attribute: " + sessionElement + "; Value: " + sessionValue);
        }

        DEBUGGER.debug("Dumping request content:");
        @SuppressWarnings("unchecked")
        Enumeration<String> requestEnumeration = hRequest.getAttributeNames();

        while (requestEnumeration.hasMoreElements()) {
            String requestElement = requestEnumeration.nextElement();
            Object requestValue = hRequest.getAttribute(requestElement);

            DEBUGGER.debug("Attribute: " + requestElement + "; Value: " + requestValue);
        }

        DEBUGGER.debug("Dumping request parameters:");
        @SuppressWarnings("unchecked")
        Enumeration<String> paramsEnumeration = hRequest.getParameterNames();

        while (paramsEnumeration.hasMoreElements()) {
            String requestElement = paramsEnumeration.nextElement();
            Object requestValue = hRequest.getParameter(requestElement);

            DEBUGGER.debug("Parameter: " + requestElement + "; Value: " + requestValue);
        }
    }

    try {
        CareerRequest request = new CareerRequest();
        request.setLang(
                (StringUtils.isBlank(hRequest.getParameter("lang"))) ? "en" : hRequest.getParameter("lang"));

        if (DEBUG) {
            DEBUGGER.debug("CareerRequest: {}", request);
        }

        CareerResponse response = this.careerRefSvc.getCareerList(request);

        if (DEBUG) {
            DEBUGGER.debug("CareerResponse: {}", response);
        }

        if (response.getRequestStatus() == CoreServicesStatus.SUCCESS) {
            mView.addObject("doCareersExist", Boolean.TRUE);
        }
    } catch (CareerRequestException crx) {
        ERROR_RECORDER.error(crx.getMessage(), crx);
    }

    mView.setViewName(this.aboutUsPage);

    if (DEBUG) {
        DEBUGGER.debug("ModelAndView: {}", mView);
    }

    return mView;
}

From source file:com.cws.us.pws.controllers.AboutController.java

@RequestMapping(value = "/careers", method = RequestMethod.GET)
public final ModelAndView showCareersPage() {
    final String methodName = AboutController.CNAME + "#showCareersPage()";

    if (DEBUG) {//from w ww  .j a v a  2  s  . com
        DEBUGGER.debug(methodName);
    }

    ModelAndView mView = new ModelAndView();

    final ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder
            .currentRequestAttributes();
    final HttpServletRequest hRequest = requestAttributes.getRequest();
    final HttpSession hSession = hRequest.getSession();

    if (DEBUG) {
        DEBUGGER.debug("ServletRequestAttributes: {}", requestAttributes);
        DEBUGGER.debug("HttpServletRequest: {}", hRequest);
        DEBUGGER.debug("HttpSession: {}", hSession);

        DEBUGGER.debug("Dumping session content:");
        @SuppressWarnings("unchecked")
        Enumeration<String> sessionEnumeration = hSession.getAttributeNames();

        while (sessionEnumeration.hasMoreElements()) {
            String sessionElement = sessionEnumeration.nextElement();
            Object sessionValue = hSession.getAttribute(sessionElement);

            DEBUGGER.debug("Attribute: " + sessionElement + "; Value: " + sessionValue);
        }

        DEBUGGER.debug("Dumping request content:");
        @SuppressWarnings("unchecked")
        Enumeration<String> requestEnumeration = hRequest.getAttributeNames();

        while (requestEnumeration.hasMoreElements()) {
            String requestElement = requestEnumeration.nextElement();
            Object requestValue = hRequest.getAttribute(requestElement);

            DEBUGGER.debug("Attribute: " + requestElement + "; Value: " + requestValue);
        }

        DEBUGGER.debug("Dumping request parameters:");
        @SuppressWarnings("unchecked")
        Enumeration<String> paramsEnumeration = hRequest.getParameterNames();

        while (paramsEnumeration.hasMoreElements()) {
            String requestElement = paramsEnumeration.nextElement();
            Object requestValue = hRequest.getParameter(requestElement);

            DEBUGGER.debug("Parameter: " + requestElement + "; Value: " + requestValue);
        }
    }

    try {
        CareerRequest request = new CareerRequest();
        request.setLang(
                (StringUtils.isBlank(hRequest.getParameter("lang"))) ? "en" : hRequest.getParameter("lang"));

        if (DEBUG) {
            DEBUGGER.debug("CareerRequest: {}", request);
        }

        CareerResponse response = this.careerRefSvc.getCareerList(request);

        if (DEBUG) {
            DEBUGGER.debug("CareerResponse: {}", response);
        }

        if (response.getRequestStatus() == CoreServicesStatus.SUCCESS) {
            mView.addObject("careerList", response.getCareerList());
        }
    } catch (CareerRequestException crx) {
        ERROR_RECORDER.error(crx.getMessage(), crx);
    }

    mView.setViewName(this.careersPage);

    if (DEBUG) {
        DEBUGGER.debug("ModelAndView: {}", mView);
    }

    return mView;
}

From source file:com.cws.us.pws.controllers.AboutController.java

@RequestMapping(value = "/careers/career/{reqId}", method = RequestMethod.GET)
public final ModelAndView showCareer(@PathVariable("reqId") final String reqId) {
    final String methodName = AboutController.CNAME
            + "#showCareer(@PathVariable(\"reqId\") final String reqId)";

    if (DEBUG) {/*from w w  w  .java  2s  .  co m*/
        DEBUGGER.debug(methodName);
    }

    ModelAndView mView = new ModelAndView();

    final ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder
            .currentRequestAttributes();
    final HttpServletRequest hRequest = requestAttributes.getRequest();
    final HttpSession hSession = hRequest.getSession();

    if (DEBUG) {
        DEBUGGER.debug("ServletRequestAttributes: {}", requestAttributes);
        DEBUGGER.debug("HttpServletRequest: {}", hRequest);
        DEBUGGER.debug("HttpSession: {}", hSession);

        DEBUGGER.debug("Dumping session content:");
        @SuppressWarnings("unchecked")
        Enumeration<String> sessionEnumeration = hSession.getAttributeNames();

        while (sessionEnumeration.hasMoreElements()) {
            String sessionElement = sessionEnumeration.nextElement();
            Object sessionValue = hSession.getAttribute(sessionElement);

            DEBUGGER.debug("Attribute: " + sessionElement + "; Value: " + sessionValue);
        }

        DEBUGGER.debug("Dumping request content:");
        @SuppressWarnings("unchecked")
        Enumeration<String> requestEnumeration = hRequest.getAttributeNames();

        while (requestEnumeration.hasMoreElements()) {
            String requestElement = requestEnumeration.nextElement();
            Object requestValue = hRequest.getAttribute(requestElement);

            DEBUGGER.debug("Attribute: " + requestElement + "; Value: " + requestValue);
        }

        DEBUGGER.debug("Dumping request parameters:");
        @SuppressWarnings("unchecked")
        Enumeration<String> paramsEnumeration = hRequest.getParameterNames();

        while (paramsEnumeration.hasMoreElements()) {
            String requestElement = paramsEnumeration.nextElement();
            Object requestValue = hRequest.getParameter(requestElement);

            DEBUGGER.debug("Parameter: " + requestElement + "; Value: " + requestValue);
        }
    }

    try {
        Career career = new Career();
        career.setJobReqId(reqId);

        if (DEBUG) {
            DEBUGGER.debug("Career: {}", career);
        }

        CareerRequest request = new CareerRequest();
        request.setCareer(career);
        request.setLang(
                (StringUtils.isBlank(hRequest.getParameter("lang"))) ? "en" : hRequest.getParameter("lang"));

        if (DEBUG) {
            DEBUGGER.debug("CareerRequest: {}", request);
        }

        CareerResponse response = this.careerRefSvc.getCareerData(request);

        if (DEBUG) {
            DEBUGGER.debug("CareerResponse: {}", response);
        }

        if (response.getRequestStatus() == CoreServicesStatus.SUCCESS) {
            mView.addObject("career", response.getCareer());
        } else {
            mView.addObject(Constants.ERROR_MESSAGE, this.messageNoCareerLocated);
        }
    } catch (CareerRequestException crx) {
        ERROR_RECORDER.error(crx.getMessage(), crx);

        mView = new ModelAndView(new RedirectView());
        mView.setViewName(this.appConfig.getErrorResponsePage());
    }

    mView.setViewName(this.careersPage);

    if (DEBUG) {
        DEBUGGER.debug("ModelAndView: {}", mView);
    }

    return mView;
}

From source file:de.betterform.agent.web.filter.XFormsFilter.java

private Map handleResponseReplaceAll(HttpServletRequest request, HttpServletResponse response)
        throws IOException {
    Map submissionResponse = null;

    HttpSession session = request.getSession(false);
    WebProcessor webProcessor = WebUtil.getWebProcessor(request, response, session);
    if (session != null && webProcessor != null) {
        if (LOG.isDebugEnabled()) {
            Enumeration keys = session.getAttributeNames();
            if (keys.hasMoreElements()) {
                LOG.debug("--- existing keys in session --- ");
            }// w  w  w  . j  ava2s .  c  o  m
            while (keys.hasMoreElements()) {
                String s = (String) keys.nextElement();
                LOG.debug("existing sessionkey: " + s + ":" + session.getAttribute(s));
            }
        }

        submissionResponse = webProcessor.checkForExitEvent().getContextInfo();
        if (submissionResponse != null) {

            if (LOG.isDebugEnabled()) {
                LOG.debug("handling submission/@replace='all'");
                Enumeration keys = session.getAttributeNames();
                if (keys.hasMoreElements()) {
                    LOG.debug("--- existing keys in http session  --- ");
                    while (keys.hasMoreElements()) {
                        String s = (String) keys.nextElement();
                        LOG.debug("existing sessionkey: " + s + ":" + session.getAttribute(s));
                    }
                } else {
                    LOG.debug("--- no keys left in http session  --- ");
                }
            }

            // copy header fields
            Map headerMap = (Map) submissionResponse.get("header");
            String name;
            String value;
            Iterator iterator = headerMap.keySet().iterator();
            while (iterator.hasNext()) {
                name = (String) iterator.next();
                if (name.equalsIgnoreCase("Transfer-Encoding")) {
                    // Some servers (e.g. WebSphere) may set a "Transfer-Encoding"
                    // with the value "chunked". This may confuse the client since
                    // XFormsServlet output is not encoded as "chunked", so this
                    // header is ignored.
                    continue;
                }

                value = (String) headerMap.get(name);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("added header: " + name + "=" + value);
                }

                response.setHeader(name, value);
            }

            //kill XFormsSession
            WebUtil.removeSession(webProcessor.getKey());
        }
    }

    return submissionResponse;
}

From source file:org.apache.click.util.ErrorReport.java

/**
 * Return a error report HTML &lt;div&gt; element for the given error and
 * page. The HTML &lt;div&gt; element 'id' and 'class' attribute values are
 * 'errorReport'./*ww w .ja v  a2s  . c  o  m*/
 *
 * @return a error HTML display string
 */
@SuppressWarnings("unchecked")
public String toString() {

    if (isProductionMode()) {
        Locale locale = request.getLocale();
        ResourceBundle bundle = ClickUtils.getBundle("click-control", locale);
        return bundle.getString("production-error-message");
    }

    HtmlStringBuffer buffer = new HtmlStringBuffer(10 * 1024);

    Throwable cause = getCause();

    buffer.append("<div id='errorReport' class='errorReport'>\n");

    // Exception table
    buffer.append(
            "<table border='1' cellspacing='1' cellpadding='4' width='100%' style='background-color: white;'>");
    if (isParseError()) {
        buffer.append(
                "<tr><td colspan='2' style='color:white; background-color: navy; font-weight: bold'>Page Parsing Error</td></tr>");
        buffer.append("<tr><td width='12%'><b>Source</b></td><td>");
        buffer.append(getSourceName());
        buffer.append("</td></tr>");
    } else {
        buffer.append(
                "<tr><td colspan='2' style='color:white; background-color: navy; font-weight: bold'>Exception</td></tr>");
        buffer.append("<tr><td width='12%'><b>Class</b></td><td>");
        buffer.append(cause.getClass().getName());
        buffer.append("</td></tr>");
    }
    buffer.append("<tr><td valign='top' width='12%'><b>Message</b></td><td>");
    buffer.append(getMessage());
    buffer.append("</td></tr>");
    if (getSourceReader() != null) {
        buffer.append("<tr><td valign='top' colspan='2'>\n");
        buffer.append(getRenderedSource());
        buffer.append("</td></tr>");
    }
    if (!isParseError()) {
        buffer.append("<tr><td valign='top' colspan='2'>\n");
        buffer.append(getStackTrace());
        buffer.append("</td></tr>");
    }
    buffer.append("</table>");
    buffer.append("<br/>");

    // Page table
    buffer.append(
            "<table border='1' cellspacing='1' cellpadding='4' width='100%' style='background-color: white;'>");
    buffer.append(
            "<tr><td colspan='2' style='color:white; background-color: navy; font-weight: bold'>Page</td></tr>");
    buffer.append("<tr><td width='12%'><b>Classname</b></td><td>");
    if (pageClass != null) {
        buffer.append(pageClass.getName());
    }
    buffer.append("</td></tr>");
    buffer.append("<tr><td width='12%'><b>Path</b></td><td>");
    buffer.append(ClickUtils.getResourcePath(request));
    buffer.append("</td></tr>");
    buffer.append("</table>");
    buffer.append("<br/>");

    // Request table
    buffer.append(
            "<table border='1' cellspacing='1' cellpadding='4' width='100%' style='background-color: white;'>");
    buffer.append(
            "<tr><td colspan='2' style='color:white; background-color: navy; font-weight: bold'>Request</td></tr>");

    Map<String, Object> requestAttributes = new TreeMap<String, Object>();
    Enumeration attributeNames = request.getAttributeNames();
    while (attributeNames.hasMoreElements()) {
        String name = attributeNames.nextElement().toString();
        requestAttributes.put(name, request.getAttribute(name));
    }
    buffer.append("<tr><td width='12%' valign='top'><b>Attributes</b></td><td>");
    writeMap(requestAttributes, buffer);
    buffer.append("</td></tr>");

    buffer.append("<tr><td width='12%'><b>Auth Type</b></td><td>");
    buffer.append(request.getAuthType());
    buffer.append("</td></tr>");

    buffer.append("<tr><td width='12%'><b>Context Path</b></td><td>");
    buffer.append("<a href='");
    buffer.append(request.getContextPath());
    buffer.append("'>");
    buffer.append(request.getContextPath());
    buffer.append("</a>");
    buffer.append("</td></tr>");

    Map<String, Object> requestHeaders = new TreeMap<String, Object>();
    Enumeration headerNames = request.getHeaderNames();
    while (headerNames.hasMoreElements()) {
        String name = headerNames.nextElement().toString();
        requestHeaders.put(name, request.getHeader(name));
    }
    buffer.append("<tr><td width='12%' valign='top'><b>Headers</b></td><td>");
    writeMap(requestHeaders, buffer);
    buffer.append("</td></tr>");

    buffer.append("<tr><td width='12%'><b>Query</b></td><td>");
    buffer.append(request.getQueryString());
    buffer.append("</td></tr>");

    buffer.append("<tr><td width='12%'><b>Method</b></td><td>");
    buffer.append(request.getMethod());
    buffer.append("</td></tr>");

    Map<String, Object> requestParams = new TreeMap<String, Object>();
    Enumeration paramNames = request.getParameterNames();
    while (paramNames.hasMoreElements()) {
        String name = paramNames.nextElement().toString();
        requestParams.put(name, request.getParameter(name));
    }
    buffer.append("<tr><td width='12%' valign='top'><b>Parameters</b></td><td>");
    writeMap(requestParams, buffer);
    buffer.append("</td></tr>");

    buffer.append("<tr><td width='12%'><b>Remote User</b></td><td>");
    buffer.append(request.getRemoteUser());
    buffer.append("</td></tr>");

    buffer.append("<tr><td width='12%' valign='top'><b>URI</b></td><td>");
    buffer.append("<a href='");
    String requestURI = ClickUtils.getRequestURI(request);
    buffer.append(requestURI);
    buffer.append("'>");
    buffer.append(requestURI);
    buffer.append("</a>");
    buffer.append("</td></tr>");

    buffer.append("<tr><td><b width='12%'>URL</b></td><td>");
    buffer.append("<a href='");
    buffer.append(request.getRequestURL());
    buffer.append("'>");
    buffer.append(request.getRequestURL());
    buffer.append("</a>");
    buffer.append("</td></tr>");

    Map<String, Object> sessionAttributes = new TreeMap<String, Object>();
    if (request.getSession(false) != null) {
        HttpSession session = request.getSession();
        attributeNames = session.getAttributeNames();
        while (attributeNames.hasMoreElements()) {
            String name = attributeNames.nextElement().toString();
            sessionAttributes.put(name, session.getAttribute(name));
        }
    }
    buffer.append("<tr><td width='12%' valign='top'><b>Session</b></td><td>");
    writeMap(sessionAttributes, buffer);
    buffer.append("</td></tr>");
    buffer.append("</table>\n");

    buffer.append("</div>\n");

    return buffer.toString();
}

From source file:org.dbflute.saflute.web.servlet.filter.RequestLoggingFilter.java

protected void buildSessionAttributes(StringBuilder sb, HttpServletRequest request) {
    final HttpSession session = request.getSession(false);
    if (session == null) {
        return;//from w  ww  .  j  av a  2  s.com
    }
    for (Iterator<?> it = toSortedSet(session.getAttributeNames()).iterator(); it.hasNext();) {
        final String name = (String) it.next();
        final Object attr = session.getAttribute(name);
        sb.append(IND);
        sb.append("[session] ").append(name).append("=");
        sb.append(filterAttributeDisp(attr));
        sb.append(LF);
    }
}