httpsession

How do I get a list of all HttpSession objects in a web application?

三世轮回 提交于 2019-11-27 02:58:10
Let's say I have a running Java-based web application with 0 or more valid HttpSession objects associated with it. I want a way to access the current list of valid HttpSession objects. I was thinking that I could implement an HttpSessionListener and use it to append to a list of session id values that are stored in an application-scoped attribute, but then I'm on the hook to update the list as sessions are invalidated and who knows what else. Before I start baking my own solution I thought I should ask the question: Does the servlet API provide some means of getting access to the complete list

Generating a new ASP.NET session in the current HTTPContext

↘锁芯ラ 提交于 2019-11-26 18:42:15
As a result of a penetration test against some of our products in the pipeline, what looked to be at the time an 'easy' problem to fix is turning out to be a toughy. Not that it should of course, I mean why would just generating a brand new session for the current HTTPContext be so difficult? Bizarre! Anyway- I've written a cheeky little utility class to "just do it": (apologies for code formatting/highlighting/Visual Basic I must be doing something wrong) Imports System.Web Imports System.Web.SessionState Public Class SwitchSession Public Shared Sub SetNewSession(ByVal context As HttpContext)

Accessing ServletContext and HttpSession in @OnMessage of a JSR-356 @ServerEndpoint

旧巷老猫 提交于 2019-11-26 15:59:22
问题 I need to get the ServletContext from inside a @ServerEndpoint in order to find Spring ApplicationContext and lookup for a Bean. For the moment my best approach is to bind that bean in the JNDI naming context and lookup it in the Endpoint . Any better solution is welcome. I'm also looking for a reasonable way to sync servlet's HttpSession with websocket's Session . 回答1: The servlet HttpSession is in JSR-356 available by HandshakeRequest#getHttpSession() which is in turn available when a

How can i load Java HttpSession from JSESSIONID?

半腔热情 提交于 2019-11-26 15:58:27
问题 I want to get Java HttpSession by JSESSIONID. Is it possible? If yes, how? 回答1: You need to collect them all in a Map using a HttpSessionListener yourself. public class HttpSessionCollector implements HttpSessionListener { private static final Map<String, HttpSession> sessions = new HashMap<String, HttpSession>(); @Override public void sessionCreated(HttpSessionEvent event) { HttpSession session = event.getSession(); sessions.put(session.getId(), session); } @Override public void

How do you store Java objects in HttpSession?

风格不统一 提交于 2019-11-26 13:21:34
So I am trying to get a servlet to add a Java object to the session of the user, when this servlet is requested. But after the servlet redirects to the next page and I try to retrieve the object, I get a null object instead. Here is what I do to add the object to the HttpSession (in the servlet): request.setAttribute("object", obj); Then I try to retrieve it by (in the JSP): Object obj = request.getAttribute("object"); So how would I get obj to not be null? Update: I have also tried this with nothing: HttpSession session = request.getSession(); session.setAttribute("object", obj); with the

Spring 3 MVC accessing HttpRequest from controller

人走茶凉 提交于 2019-11-26 12:58:36
I would like to handle request and session attributes myself rather then leave it to spring @SessionAttributes , for login of cookies handling for example. I just cant figure out how could I access the HttpRequest from within a controller, I need a way to go a layer above the @RequestAttribute and access the HttpRequest itself. With Stripes in used to do this by implementing an ApplicationContext and calling getAttribute() . Also, passing the HttpServletRequest as parameter seems not to be working: @RequestMapping(value="/") public String home(HttpServletRequest request){ System.out.println(""

How do I get a list of all HttpSession objects in a web application?

回眸只為那壹抹淺笑 提交于 2019-11-26 12:36:26
问题 Let\'s say I have a running Java-based web application with 0 or more valid HttpSession objects associated with it. I want a way to access the current list of valid HttpSession objects. I was thinking that I could implement an HttpSessionListener and use it to append to a list of session id values that are stored in an application-scoped attribute, but then I\'m on the hook to update the list as sessions are invalidated and who knows what else. Before I start baking my own solution I thought

Using a Stateful Session Bean to track an user&#39;s session

不想你离开。 提交于 2019-11-26 12:09:47
问题 it\'s my first question here and I hope that I\'m doing it right. I need to work on a Java EE project, so, before starting, I\'m trying to do something simple and see if I can do that. I\'m stuck with Stateful Session Beans . Here\'s the question : How can I use a SFSB to track an user\'s session? All the examples that I saw, ended up in \"putting\" the SFSB into a HttpSession attribute. But I don\'t understand why! I mean, if the bean is STATEFUL, why do I have to use the HttpSession to keep

Generating a new ASP.NET session in the current HTTPContext

£可爱£侵袭症+ 提交于 2019-11-26 06:31:19
问题 As a result of a penetration test against some of our products in the pipeline, what looked to be at the time an \'easy\' problem to fix is turning out to be a toughy. Not that it should of course, I mean why would just generating a brand new session for the current HTTPContext be so difficult? Bizarre! Anyway- I\'ve written a cheeky little utility class to \"just do it\": (apologies for code formatting/highlighting/Visual Basic I must be doing something wrong) Imports System.Web Imports

How do you store Java objects in HttpSession?

◇◆丶佛笑我妖孽 提交于 2019-11-26 02:58:04
问题 So I am trying to get a servlet to add a Java object to the session of the user, when this servlet is requested. But after the servlet redirects to the next page and I try to retrieve the object, I get a null object instead. Here is what I do to add the object to the HttpSession (in the servlet): request.setAttribute(\"object\", obj); Then I try to retrieve it by (in the JSP): Object obj = request.getAttribute(\"object\"); So how would I get obj to not be null? Update: I have also tried this