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
2
votes
1 answer

possible to implicitly re-attach all nested domain objects to Hibernate session in Grails?

I've noticed that when getting a Domain object out of the HttpSession and attaching it back to the hibernate session, it does not attach any Domain classes that are properties. For example, assuming Foo and Bar are both domain classes, and Foo is a…
Peter
  • 29,498
  • 21
  • 89
  • 122
2
votes
1 answer

How to check when the user is logged out by session expiration

I have JSF web app on glassfish using j_security_check validation with jdbcRealm on glassfish connected to MSSQL db. Is there any way to check for example if there exists active bean with given username? I just want to display on the web page who is…
xwhyz
  • 1,444
  • 4
  • 21
  • 45
2
votes
1 answer

Can I delete a HttpSession manually in a servlet?

I took a JSP class and we learnt that we should always remove all the attributes of the HttpSession before we use it. So one of my classmate asked - "How about we delete the HttpSession permanently after we've done using it?" So, my question is…
Jaycee
  • 85
  • 1
  • 1
  • 5
2
votes
1 answer

Connecting a Scope with an HttpSessionListener

I am writing an web application that allows people to collaborate. I would like to have some of my services scoped to the collaboration (which involves a few people) rather than to any individual http session. I created a custom Scope that stores…
Gene Golovchinsky
  • 6,101
  • 7
  • 53
  • 81
2
votes
2 answers

Remove session attributes which name starts from specific name

In my servlet, if I want to remove a specific session attribute I run: session.removeAttribute("user"); and I want to remove all of them: session.invalidate(); How to remove only those session attributes which their name starts from a specific…
yaylitzis
  • 5,354
  • 17
  • 62
  • 107
2
votes
2 answers

HttpSession stores attribute by reference or value?

I use HttpSession in my server application. And for the session set attributes. My question in next: how attribute for session sets - by reference or value. Question in afraid reason that would not java heap space exception and RAM saving. For…
Tioma
  • 2,120
  • 9
  • 35
  • 52
2
votes
0 answers

Spring security concurrent-session and HttpSessionListener problem

I have implemented HttpSessionListener and it works fine except for the case when a logged in user concurrently logs in a second time. Spring terminates the first session correctly, but the destroySession event is never fired, at least my listener…
kmansoor
  • 4,265
  • 9
  • 52
  • 95
2
votes
0 answers

Spring boot OAuth2Client, user not authenticated after callback: SecurityContext is empty or contents are anonymous

I'm configuring a Spring Boot application that will authenticate the user using OAuth2 and OpenID Connect. For the implementation, I follow the reference here: https://docs.spring.io/spring-security/site/docs/current/reference/html5/#oauth2 After…
2
votes
1 answer

Thymeleaf expression objects: #session and ${session....}

There are two ways to obtain a session attribute in Thymeleaf: ${#session.getAttribute('attr')} ${session.attr} What is the difference between both session "objects"? Is there a situation in which one would work and not the other?
NatFar
  • 2,090
  • 1
  • 12
  • 29
2
votes
1 answer

How to change DefaultSessionTrackingModes when HttpsSession is created

I want to change DefaultSessionTrackingModes when any HttpSession is created on basis of Login User So for that, I have created my own HttpSessionListner @WebListener public class HttpSession1TrackingModeSetter implements HttpSessionListener { …
V.P.
  • 592
  • 8
  • 20
2
votes
1 answer

How to prevent creating HttpSession in Spring REST Controller

In our project we have implemented a few REST Services using Spring @RestController. The problem is when I test them using a REST Client, in response header there exists JSESSIONID, So I believe the server creates an HTTPSession for each request,…
Amir Pashazadeh
  • 7,170
  • 3
  • 39
  • 69
2
votes
1 answer

implementing HttpSessionListener

I am facing a similar problem and have learnt that my listener class will be instantiated when the web.xml is read. I have few functions in the listener class that are used by the main servlet's doPost(which interacts with the database(mysql) to…
sarath
  • 498
  • 2
  • 12
  • 19
2
votes
2 answers

Does it make sense to set session=null after session.close()?

consider this bit of code: public void foo(){ try{ //some cool statements here } finally { if(session != null){ session.close(); sesssion = null; } } } Since the…
2
votes
1 answer

Access HTTP Session in WebSocketHandler (Spring-websocket)

Dears, I'm trying to get an HTTPSession in my WebSocketHandler. I could do it successfully when I was using 'javax.websocket-api' but I'm now using 'Spring-Websocket'. The config : @ConditionalOnWebApplication @Configuration @EnableWebSocket public…
user2447161
  • 277
  • 4
  • 12
2
votes
2 answers

Beans serialization in JSP

Why some times tutorials make beans implement Serializable object and others do not? I know that object should be serialized when I want to send it through a network, so does that prove that each bean used in sessions should implements Serializable…
palAlaa
  • 9,500
  • 33
  • 107
  • 166