Questions tagged [httpsession]

An Java interface used by the servlet container to create a session between an HTTP client and an HTTP server.

An Java interface used by the servlet container to create a session between an HTTP client and an HTTP server. The session object has an expiration time which allows the container to invalidate the session after that specified time of the user inactivity. It is active while the user making requests, across more than one connection or page and remains active after the user exit application and stay active until it's expired. The server persists the session object for the user between restarts. While it's valid the session interface allows the application to bind objects to it and access then from different requests of the same user. A session usually corresponds to one user, who may visit a site many times. The server can maintain a session in many ways such as using cookies or rewriting URLs.

Details from the API docs:

Tutorials:

655 questions
6
votes
1 answer

Google App Engine session changes between instances

A visual aid to help you understand the issue. I am baffled because this issue has occurred 100% of the time on every application that I've tried to launch, and yet I can't find any information about this issue, and I can't find anybody else on the…
Kat
  • 507
  • 7
  • 12
6
votes
2 answers

request.getSession().getId() vs request.getRequestedSessionId()

What is the difference between request.getSession().getId() and request.getRequestedSessionId()? Do both of them return the same thing i.e. Session Id? Thanks
srh
  • 1,661
  • 4
  • 30
  • 57
6
votes
2 answers

Java HttpSession .getAttribute(String name)

I have a simple, short question but not found the answer anywhere. I created an HttpSession and want to get an attribute from it, for example a User object. HttpSession session = request.getSession(true); Object userObject =…
Display Name
  • 1,121
  • 2
  • 11
  • 14
6
votes
3 answers

How can I write extensions for Session without having to write separate methods for HttpSessionState and HttpSessionStateBase?

I wrote the following extension methods for Session so that I can persist and retrieve objects by their type. This works well for my solution, but I ended up having to duplicate my extension methods to cover the old HttpSessionState and the new…
Byron Sommardahl
  • 12,743
  • 15
  • 74
  • 131
6
votes
2 answers

HttpSession remains after server restart

I'm learning Spring. Doing the login/logout functionality. This is what my controller looks like: @RequestMapping(value="/successfulLoginAuth", method=RequestMethod.GET) public ModelAndView postHttpLogin(HttpSession session, Authentication…
Chinmay Shah
  • 85
  • 1
  • 1
  • 4
6
votes
3 answers

Spring MVC - difference between HttpSession.setAttribute and model.addObject

I am trying to learn Spring MVC recently. It seems that i did not understand well the functionalities of @ModelAttribute annotation and HttpSession. @SessionAttributes({"shoppingCart", "count"}) public class ItemController…
akcasoy
  • 6,497
  • 13
  • 56
  • 100
6
votes
3 answers

When exactly is the HttpSession expired (starts being eligible for destroying - not necessarily destroyed yet)?

I would like to know when exactly an HttpSession would be expired (not the same as destroyed)? I am trying to figure out if session.getLastAccessedTime() + (session.getMaxInactiveInterval() * 1000) will give me the exact time in milliseconds of…
despot
  • 7,167
  • 9
  • 44
  • 63
5
votes
2 answers

REST and HttpSession object

I know that REST is not supposed to use HttpSession. From the other side, the REST service is running within a servlet container. From what I saw, the HttpSession object will be created only when: HttpSession session = request.getSession(); code…
Cosigin
  • 83
  • 2
  • 5
5
votes
3 answers

java httpsession is valid?

I'm using the java servlet API in tomcat. I save in a hash table the username and the httpsession with the attribute username and I would like to know if there is a way to check if the httpsession is valid. I've tried: try { String user =…
Matteo
  • 2,029
  • 4
  • 22
  • 30
5
votes
4 answers

How to access the session from a Java class

I need to write a small Java class that will enable me to add to and read from the current user session. Everything I see refers to Servlets but I'd ideally like to just use a plain old class. Can anyone please help this Java Newbie? Thanks
griegs
  • 22,624
  • 33
  • 128
  • 205
5
votes
3 answers

How to get the IP address when a session is created?

In my grails application, I have implemented the interface HttpSessionListener to listen for session creation as given below: class MyHttpSessionListener implements HttpSessionListener { public void sessionCreated(HttpSessionEvent event) { …
fabien7474
  • 16,300
  • 22
  • 96
  • 124
5
votes
3 answers

JSP Servlet session invalidate() does not make session null

I have three simple HttpServlet classes in my JSP project, "LoginServlet", "LogoutServlet" and "ProfileServlet". LoginServlet: log in user by setting "name" attribute to session LogoutServlet: log out user and invalidate session ProfileServlet:…
alextc
  • 3,206
  • 10
  • 63
  • 107
5
votes
1 answer

Is it possible to view HttpSession attributes with client side exploit?

I have recently started to maintain an online system. It is using JSF with PrimeFaces for the front end, with a Java backend. JSF is a new technology for me. During the login process the whole user table (including clear text passwords (will soon be…
ufis
  • 176
  • 1
  • 11
5
votes
2 answers

How to find out what open sessions my servlet based application is handling at any given moment

I need to write a servlet that, when called, gets information about a list of the currently opened sessions. Is there a way to do this?
Yevgeny Simkin
  • 27,946
  • 39
  • 137
  • 236
5
votes
1 answer

Accessing values stored in HttpSession using JavaScript

Here is my Spring MVC Controller code: session.setAttribute("YourProperty", "arg1"); How can I access an attribute stored in my HttpSession using JavaScript? I have tried using this code: var property =…
edaklij
  • 4,121
  • 11
  • 31
  • 43