httpsession

Websocket - httpSession returns null

孤人 提交于 2019-11-28 02:48:48
问题 I would like to make the connection between a websocket handshake \ session to a HttpSession object. I've used the following handshake modification: public class GetHttpSessionConfigurator extends ServerEndpointConfig.Configurator { @Override public void modifyHandshake(ServerEndpointConfig config, HandshakeRequest request, HandshakeResponse response) { HttpSession httpSession = (HttpSession)request.getHttpSession(); config.getUserProperties().put(HttpSession.class.getName(),httpSession); } }

Sturts 2 session invalidation with setting request session to a new session

感情迁移 提交于 2019-11-28 01:59:05
问题 In my Struts application once an user login I need to invalidate the current session and create a new session. I invalidate the session with getHttpServletRequest().getSession().invalidate(); And I create a new session as getHttpServletRequest().getSession(true); The problem here is after above I try to access getSession() it gives the state invalid exception; HttpSession is invalid. getSession() returns a map where in my action class I implements SessionAware which has the setSession(Map

How can I manually load a Java session using a JSESSIONID?

穿精又带淫゛_ 提交于 2019-11-27 18:00:56
I have a servlet which handles a multipart form post. The post is actually being made by a Flash file upload component embedded in the page. In some browsers, the Flash-generated POST doesn't include the JSESSIONID which is making it impossible for me to load certain information from the session during the post. The flash upload component does include cookie and session information within a special form field. Using this form field, I can actually retrieve the JSESSIONID value. The problem is, I don't know how to use this JSESSIONID value to manually load that specific session. Edit - Based on

Tomcat, keep session when moving from HTTPS to HTTP

ⅰ亾dé卋堺 提交于 2019-11-27 13:12:49
问题 I have a Java application running on Tomcat 6.0.29, with Apache 2.2.3 in front. The login page uses HTTPS, while most pages use HTTP. If a user tries to access a page (HTTP) that is login protected, he gets redirected to the login page (HTTPS), logs in, then gets redirected back to the originally requested page. This works great, as the JSESSIONID cookie is set as non-secure, and used for both HTTP and HTTPS. However, if the user starts at the login page (HTTPS), the JSESSIONID cookie is set

How can i load Java HttpSession from JSESSIONID?

牧云@^-^@ 提交于 2019-11-27 12:13:01
I want to get Java HttpSession by JSESSIONID. Is it possible? If yes, how? BalusC 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 sessionDestroyed(HttpSessionEvent event) { sessions.remove(event.getSession().getId()); } public static

How to check if a session is invalid

做~自己de王妃 提交于 2019-11-27 10:31:19
问题 How to check if a session is invalid or not? There is no method in the API. Is it the same as isNew() ? And what is the difference if not? 回答1: If you want to know whether it valid based on a request: request.isRequestedSessionIdValid() or HttpSession sess = request.getSession(false); if (sess != null) { // it's valid } If you have stored a reference to the session and need to validate I would try { long sd = session.getCreationTime(); } catch (IllegalStateException ise) { // it's invalid }

I can get property from a session attribute, but not from a session map

柔情痞子 提交于 2019-11-27 07:27:30
问题 I am using SSH2. When I try to got an attribute with <%=session.getAttribute("username") %> , it was just right. But when I tried to get the same attribute with <s:property value="#session.username" /> , I got nothing. Why? Aren't they the same? And when I used the <s:debug> , I got these: Servlet.service() for servlet jsp threw exception org.hibernate.LazyInitializationException: could not initialize proxy - no Session at org.hibernate.proxy.AbstractLazyInitializer.initialize

Using a Stateful Session Bean to track an user's session

不问归期 提交于 2019-11-27 06:46:08
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 it? Isn't an EJB Container's task to return the right SFSB to the client? I've tried with a simple counter bean

How to inject dependencies into HttpSessionListener, using Spring?

好久不见. 提交于 2019-11-27 04:36:45
How to inject dependencies into HttpSessionListener, using Spring and without calls, like context.getBean("foo-bar") ? Yinzara Since the Servlet 3.0 ServletContext has an "addListener" method, instead of adding your listener in your web.xml file you could add through code like so: @Component public class MyHttpSessionListener implements javax.servlet.http.HttpSessionListener, ApplicationContextAware { @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { if (applicationContext instanceof WebApplicationContext) { ((WebApplicationContext)

How to stop Spring Security from creating a new session?

六月ゝ 毕业季﹏ 提交于 2019-11-27 03:40:07
问题 Scenario I restart the server and browser so there's no session data. I go to www.someurl.com public access page. My controller gets me a session with this HttpSession session=request.getSession(true); I click on a plane anchor link to www.someurl.com/admin restricted access page which opens in a new tab. Spring Security 3 intercepts this and challenges for credentials. I log in successfully. I go back to the previous tab with www.someurl.com and refresh the page. Problem What I notice in my