Example usage for javax.servlet.http HttpSession hashCode

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

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public native int hashCode();

Source Link

Document

Returns a hash code value for the object.

Usage

From source file:org.kmnet.com.fw.web.logging.mdc.XTrackMDCPutFilter.java

/**
 * MDC????./*w ww.ja v  a  2  s.c o m*/
 * 
 * @param request
 *            
 * @param response
 *            ?
 * @param chain
 *            ?
 * @throws IOException
 *             I/O
 * @throws ServletException
 *             
 */
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
        FilterChain filterChain) throws ServletException, IOException {
    MDC.put(REQUEST_ID, RandomStringUtils.randomAlphanumeric(RANDAM_FORMAT_LENGTH));

    HttpSession session = ((HttpServletRequest) request).getSession(true);
    // sessionid??????????????????
    String sessionIdentifier = (Integer.toHexString(session.hashCode()));
    MDC.put(SESSION_ID, sessionIdentifier);

    // ------------------------
    // Filter?
    // ------------------------
    try {
        filterChain.doFilter(request, response);
    } finally {

        // ------------------------
        // ?
        // ------------------------
        MDC.remove(REQUEST_ID);
        MDC.remove(SESSION_ID);
    }

}