java.lang.IllegalStateException: getAttribute: Session already invalidated

I never worked with WebLogic, but from JavaDoc here I can tell that calling getPortletSession() is already wrong idea if you want to invalidate existing session, because it’s said in JavaDocs: Returns the current portlet session or, if there is no current session, creates one and returns the new session. So, it creates a new … Read more

How to check if a session is invalid

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 … Read more

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

There is no API to retrieve session by id. What you can do, however, is implement a session listener in your web application and manually maintain a map of sessions keyed by id (session id is retrievable via session.getId()). You will then be able to retrieve any session you want (as opposed to tricking container … Read more

How to store session in Spring MVC

Session-scoped beans (using scope=”session”) is the cleanest approach. This removes the need to interact with the session yourself. If you want to autowire a session-scoped bean in to the controller, you either need to make the controller session-scoped itself, or use a scoped-proxy to wire it into a singleton controller, as described here. Either approach … Read more

How do you store Java objects in HttpSession?

You are not adding the object to the session, instead you are adding it to the request. What you need is: HttpSession session = request.getSession(); session.setAttribute(“MySessionVariable”, param); In Servlets you have 4 scopes where you can store data. Application Session Request Page Make sure you understand these. For more look here

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

No, the Servlet API doesn’t provide a way. You really have to get hold of them all with help of a HttpSessionListener. You can find several examples in the following answers: How to find HttpSession by jsessionid? How to find number of active sessions per IP? How to check Who’s Online? How to invalidate another … Read more

How to invalidate session in JSF 2.0?

Firstly, is this method correct? Is there a way without touching the ServletAPI? You can use ExternalContext#invalidateSession() to invalidate the session without the need to grab the Servlet API. @ManagedBean @SessionScoped public class UserManager { private User current; public String logout() { FacesContext.getCurrentInstance().getExternalContext().invalidateSession(); return “/home.xhtml?faces-redirect=true”; } // … } what will happen to my current … Read more

Spring 3 MVC accessing HttpRequest from controller

Spring MVC will give you the HttpRequest if you just add it to your controller method signature: For instance: /** * Generate a PDF report… */ @RequestMapping(value = “/report/{objectId}”, method = RequestMethod.GET) public @ResponseBody void generateReport( @PathVariable(“objectId”) Long objectId, HttpServletRequest request, HttpServletResponse response) { // … // Here you can use the request and response … Read more