All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jeesuite.security.RequestContextHolder Maven / Gradle / Ivy

There is a newer version: 1.4.0
Show newest version
package com.jeesuite.security;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class RequestContextHolder {

	private static final ThreadLocal holder = new ThreadLocal<>();
	
	
	public static void set(HttpServletRequest request, HttpServletResponse response){
		holder.set(new RequestResponsePair(request, response));
	}
	
	public static HttpServletRequest getRequest() {
		return holder.get().request;
	}
	
	public static HttpServletResponse getResponse() {
		return holder.get() == null ? null : holder.get().response;
	}
	
	private static class RequestResponsePair{
		HttpServletRequest request;
		HttpServletResponse response;
		
		
		public RequestResponsePair(HttpServletRequest request, HttpServletResponse response) {
			super();
			this.request = request;
			this.response = response;
		}
		
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy