当前位置: 首页>>代码示例>>Java>>正文


Java Request.getSession方法代码示例

本文整理汇总了Java中org.apache.catalina.connector.Request.getSession方法的典型用法代码示例。如果您正苦于以下问题:Java Request.getSession方法的具体用法?Java Request.getSession怎么用?Java Request.getSession使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.catalina.connector.Request的用法示例。


在下文中一共展示了Request.getSession方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addElement

import org.apache.catalina.connector.Request; //导入方法依赖的package包/类
@Override
public void addElement(StringBuilder buf, Date date, Request request,
        Response response, long time) {
    Object value = null;
    if (null != request) {
        HttpSession sess = request.getSession(false);
        if (null != sess) {
            value = sess.getAttribute(header);
        }
    } else {
        value = "??";
    }
    if (value != null) {
        if (value instanceof String) {
            buf.append((String) value);
        } else {
            buf.append(value.toString());
        }
    } else {
        buf.append('-');
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:23,代码来源:AccessLogValve.java

示例2: addElement

import org.apache.catalina.connector.Request; //导入方法依赖的package包/类
public void addElement(StringBuffer buf, Date date, Request request,
        Response response, long time) {
    Object value = null;
    if (null != request) {
        HttpSession sess = request.getSession(false);
        if (null != sess)
            value = sess.getAttribute(header);
    } else {
        value = "??";
    }
    if (value != null) {
        if (value instanceof String) {
            buf.append((String) value);
        } else {
            buf.append(value.toString());
        }
    } else {
        buf.append('-');
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:AccessLogValve.java

示例3: addElement

import org.apache.catalina.connector.Request; //导入方法依赖的package包/类
@Override
public void addElement(StringBuilder buf, Date date, Request request, Response response, long time) {
	Object value = null;
	if (null != request) {
		HttpSession sess = request.getSession(false);
		if (null != sess) {
			value = sess.getAttribute(header);
		}
	} else {
		value = "??";
	}
	if (value != null) {
		if (value instanceof String) {
			buf.append((String) value);
		} else {
			buf.append(value.toString());
		}
	} else {
		buf.append('-');
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:22,代码来源:AccessLogValve.java

示例4: addElement

import org.apache.catalina.connector.Request; //导入方法依赖的package包/类
@Override
public void addElement(StringBuilder buf, Date date, Request request,
        Response response, long time) {
    HttpSession session = null;
    if (request != null) {
        session = request.getSession(false);
        if (session != null) {
            buf.append(wrap(session.getAttribute(attribute)));
        }
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:12,代码来源:ExtendedAccessLogValve.java

示例5: invoke

import org.apache.catalina.connector.Request; //导入方法依赖的package包/类
/**
 * Register requests for tracking, whenever needed.
 *
 * @param request The servlet request to be processed
 * @param response The servlet response to be created
 *
 * @exception IOException if an input/output error occurs
 * @exception ServletException if a servlet error occurs
 */
@Override
public void invoke(Request request, Response response)
    throws IOException, ServletException {
    // Perform the request
    getNext().invoke(request, response);

    if (request.isComet() && !response.isClosed()) {
        // Start tracking this connection, since this is a
        // begin event, and Comet mode is on
        HttpSession session = request.getSession(true);

        // Track the connection for webapp reload
        cometRequests.add(request);

        // Track the connection for session expiration
        synchronized (session) {
            Request[] requests = (Request[])
                    session.getAttribute(cometRequestsAttribute);
            if (requests == null) {
                requests = new Request[1];
                requests[0] = request;
                session.setAttribute(cometRequestsAttribute,
                        requests);
            } else {
                Request[] newRequests =
                    new Request[requests.length + 1];
                for (int i = 0; i < requests.length; i++) {
                    newRequests[i] = requests[i];
                }
                newRequests[requests.length] = request;
                session.setAttribute(cometRequestsAttribute, newRequests);
            }
        }
    }

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:46,代码来源:CometConnectionManagerValve.java

示例6: addElement

import org.apache.catalina.connector.Request; //导入方法依赖的package包/类
public void addElement(StringBuffer buf, Date date, Request request,
        Response response, long time) {
    HttpSession session = null;
    if (request != null) {
        session = request.getSession(false);
        if (session != null)
            buf.append(wrap(session.getAttribute(attribute)));
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:ExtendedAccessLogValve.java

示例7: invoke

import org.apache.catalina.connector.Request; //导入方法依赖的package包/类
/**
 * Register requests for tracking, whenever needed.
 *
 * @param request The servlet request to be processed
 * @param response The servlet response to be created
 *
 * @exception IOException if an input/output error occurs
 * @exception ServletException if a servlet error occurs
 */
public void invoke(Request request, Response response)
    throws IOException, ServletException {
    // Perform the request
    getNext().invoke(request, response);
    
    if (request.isComet() && !response.isClosed()) {
        // Start tracking this connection, since this is a 
        // begin event, and Comet mode is on
        HttpSession session = request.getSession(true);
        
        // Track the conection for webapp reload
        cometRequests.add(request);
        
        // Track the connection for session expiration
        synchronized (session) {
            Request[] requests = (Request[])
                    session.getAttribute(cometRequestsAttribute);
            if (requests == null) {
                requests = new Request[1];
                requests[0] = request;
                session.setAttribute(cometRequestsAttribute,
                        requests);
            } else {
                Request[] newRequests = 
                    new Request[requests.length + 1];
                for (int i = 0; i < requests.length; i++) {
                    newRequests[i] = requests[i];
                }
                newRequests[requests.length] = request;
                session.setAttribute(cometRequestsAttribute, newRequests);
            }
        }
    }
    
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:45,代码来源:CometConnectionManagerValve.java

示例8: addElement

import org.apache.catalina.connector.Request; //导入方法依赖的package包/类
@Override
public void addElement(StringBuilder buf, Date date, Request request, Response response, long time) {
	HttpSession session = null;
	if (request != null) {
		session = request.getSession(false);
		if (session != null) {
			buf.append(wrap(session.getAttribute(attribute)));
		}
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:11,代码来源:ExtendedAccessLogValve.java

示例9: invoke

import org.apache.catalina.connector.Request; //导入方法依赖的package包/类
/**
 * Register requests for tracking, whenever needed.
 *
 * @param request
 *            The servlet request to be processed
 * @param response
 *            The servlet response to be created
 *
 * @exception IOException
 *                if an input/output error occurs
 * @exception ServletException
 *                if a servlet error occurs
 */
@Override
public void invoke(Request request, Response response) throws IOException, ServletException {
	// Perform the request
	getNext().invoke(request, response);

	if (request.isComet() && !response.isClosed()) {
		// Start tracking this connection, since this is a
		// begin event, and Comet mode is on
		HttpSession session = request.getSession(true);

		// Track the connection for webapp reload
		cometRequests.add(request);

		// Track the connection for session expiration
		synchronized (session) {
			Request[] requests = (Request[]) session.getAttribute(cometRequestsAttribute);
			if (requests == null) {
				requests = new Request[1];
				requests[0] = request;
				session.setAttribute(cometRequestsAttribute, requests);
			} else {
				Request[] newRequests = new Request[requests.length + 1];
				for (int i = 0; i < requests.length; i++) {
					newRequests[i] = requests[i];
				}
				newRequests[requests.length] = request;
				session.setAttribute(cometRequestsAttribute, newRequests);
			}
		}
	}

}
 
开发者ID:how2j,项目名称:lazycat,代码行数:46,代码来源:CometConnectionManagerValve.java

示例10: invoke

import org.apache.catalina.connector.Request; //导入方法依赖的package包/类
@Override
public void invoke(Request request, Response response) throws IOException,
        ServletException {

    boolean isBot = false;
    String sessionId = null;
    String clientIp = null;

    if (log.isDebugEnabled()) {
        log.debug(request.hashCode() + ": ClientIp=" +
                request.getRemoteAddr() + ", RequestedSessionId=" +
                request.getRequestedSessionId());
    }

    // If the incoming request has a valid session ID, no action is required
    if (request.getSession(false) == null) {

        // Is this a crawler - check the UA headers
        Enumeration<String> uaHeaders = request.getHeaders("user-agent");
        String uaHeader = null;
        if (uaHeaders.hasMoreElements()) {
            uaHeader = uaHeaders.nextElement();
        }

        // If more than one UA header - assume not a bot
        if (uaHeader != null && !uaHeaders.hasMoreElements()) {

            if (log.isDebugEnabled()) {
                log.debug(request.hashCode() + ": UserAgent=" + uaHeader);
            }

            if (uaPattern.matcher(uaHeader).matches()) {
                isBot = true;

                if (log.isDebugEnabled()) {
                    log.debug(request.hashCode() +
                            ": Bot found. UserAgent=" + uaHeader);
                }
            }
        }

        // If this is a bot, is the session ID known?
        if (isBot) {
            clientIp = request.getRemoteAddr();
            sessionId = clientIpSessionId.get(clientIp);
            if (sessionId != null) {
                request.setRequestedSessionId(sessionId);
                if (log.isDebugEnabled()) {
                    log.debug(request.hashCode() + ": SessionID=" +
                            sessionId);
                }
            }
        }
    }

    getNext().invoke(request, response);

    if (isBot) {
        if (sessionId == null) {
            // Has bot just created a session, if so make a note of it
            HttpSession s = request.getSession(false);
            if (s != null) {
                clientIpSessionId.put(clientIp, s.getId());
                sessionIdClientIp.put(s.getId(), clientIp);
                // #valueUnbound() will be called on session expiration
                s.setAttribute(this.getClass().getName(), this);
                s.setMaxInactiveInterval(sessionInactiveInterval);

                if (log.isDebugEnabled()) {
                    log.debug(request.hashCode() +
                            ": New bot session. SessionID=" + s.getId());
                }
            }
        } else {
            if (log.isDebugEnabled()) {
                log.debug(request.hashCode() +
                        ": Bot session accessed. SessionID=" + sessionId);
            }
        }
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:82,代码来源:CrawlerSessionManagerValve.java

示例11: invoke

import org.apache.catalina.connector.Request; //导入方法依赖的package包/类
/**
 * Select the appropriate child Context to process this request,
 * based on the specified request URI.  If no matching Context can
 * be found, return an appropriate HTTP error.
 *
 * @param request Request to be processed
 * @param response Response to be produced
 * @param valveContext Valve context used to forward to the next Valve
 *
 * @exception IOException if an input/output error occurred
 * @exception ServletException if a servlet error occurred
 */
public final void invoke(Request request, Response response)
    throws IOException, ServletException {

    // Select the Context to be used for this Request
    Context context = request.getContext();
    if (context == null) {
        response.sendError
            (HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
             sm.getString("standardHost.noContext"));
        return;
    }

    // Bind the context CL to the current thread
    if( context.getLoader() != null ) {
        // Not started - it should check for availability first
        // This should eventually move to Engine, it's generic.
        Thread.currentThread().setContextClassLoader
                (context.getLoader().getClassLoader());
    }

    // Ask this Context to process this request
    context.getPipeline().getFirst().invoke(request, response);

    // Access a session (if present) to update last accessed time, based on a
    // strict interpretation of the specification
    if (Globals.STRICT_SERVLET_COMPLIANCE) {
        request.getSession(false);
    }

    // Error page processing
    response.setSuspended(false);

    Throwable t = (Throwable) request.getAttribute(Globals.EXCEPTION_ATTR);

    if (t != null) {
        throwable(request, response, t);
    } else {
        status(request, response);
    }

    // Restore the context classloader
    Thread.currentThread().setContextClassLoader
        (StandardHostValve.class.getClassLoader());

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:58,代码来源:StandardHostValve.java

示例12: invoke

import org.apache.catalina.connector.Request; //导入方法依赖的package包/类
@Override
public void invoke(Request request, Response response) throws IOException, ServletException {

	boolean isBot = false;
	String sessionId = null;
	String clientIp = null;

	if (log.isDebugEnabled()) {
		log.debug(request.hashCode() + ": ClientIp=" + request.getRemoteAddr() + ", RequestedSessionId="
				+ request.getRequestedSessionId());
	}

	// If the incoming request has a valid session ID, no action is required
	if (request.getSession(false) == null) {

		// Is this a crawler - check the UA headers
		Enumeration<String> uaHeaders = request.getHeaders("user-agent");
		String uaHeader = null;
		if (uaHeaders.hasMoreElements()) {
			uaHeader = uaHeaders.nextElement();
		}

		// If more than one UA header - assume not a bot
		if (uaHeader != null && !uaHeaders.hasMoreElements()) {

			if (log.isDebugEnabled()) {
				log.debug(request.hashCode() + ": UserAgent=" + uaHeader);
			}

			if (uaPattern.matcher(uaHeader).matches()) {
				isBot = true;

				if (log.isDebugEnabled()) {
					log.debug(request.hashCode() + ": Bot found. UserAgent=" + uaHeader);
				}
			}
		}

		// If this is a bot, is the session ID known?
		if (isBot) {
			clientIp = request.getRemoteAddr();
			sessionId = clientIpSessionId.get(clientIp);
			if (sessionId != null) {
				request.setRequestedSessionId(sessionId);
				if (log.isDebugEnabled()) {
					log.debug(request.hashCode() + ": SessionID=" + sessionId);
				}
			}
		}
	}

	getNext().invoke(request, response);

	if (isBot) {
		if (sessionId == null) {
			// Has bot just created a session, if so make a note of it
			HttpSession s = request.getSession(false);
			if (s != null) {
				clientIpSessionId.put(clientIp, s.getId());
				sessionIdClientIp.put(s.getId(), clientIp);
				// #valueUnbound() will be called on session expiration
				s.setAttribute(this.getClass().getName(), this);
				s.setMaxInactiveInterval(sessionInactiveInterval);

				if (log.isDebugEnabled()) {
					log.debug(request.hashCode() + ": New bot session. SessionID=" + s.getId());
				}
			}
		} else {
			if (log.isDebugEnabled()) {
				log.debug(request.hashCode() + ": Bot session accessed. SessionID=" + sessionId);
			}
		}
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:76,代码来源:CrawlerSessionManagerValve.java


注:本文中的org.apache.catalina.connector.Request.getSession方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。