Does servlet HTTP session context starts after successful authentication or exist since the clients connects the first time to the server as an anonymous user?
Asked
Active
Viewed 309 times
-1
-
Session context is created directly after whoever visit server from new client. – Milkmaid Jan 25 '16 at 07:15
-
1What Java EE session exactly are you talking about? HTTP servlet session or EJB session or JPA session or WebSocket session or JMS session or whatever session? Note that above comment and below answer seem to expect HTTP session ("visit", "site"), while the wording "context" in your question actually suggests EJB session. Nonetheless, generally a "session" always starts on first interaction of the client with the server requiring the session, regardless of the kind of session. – BalusC Jan 25 '16 at 07:24
-
@BalusC please consider posting your comment as an answer. Because it actually answers the OP question. – G. Demecki Jan 25 '16 at 07:34
-
@G.Demecki: depending on the answer, there's already a duplicate. – BalusC Jan 25 '16 at 07:38
-
1Well when i said Java EE session context i ment to say THE session context of the web tier. There are: session, request, application and conversation context. Of all those contexts i ment the session one. Thanks in advance. – EliuX Jan 25 '16 at 07:39
-
@BalusC ok, but still answering question in the comment isn't the best idea. BTW: you marked this question as "duplicated", but the referenced question, while correct, is much broader - that's why _answering here the OP question_ IMHO would be good. However thx for sharing. – G. Demecki Jan 25 '16 at 07:49
-
@G.Demecki: I don't consider that comment an answer, otherwise I'd have posted an answer. The question was just badly formulated. – BalusC Jan 25 '16 at 07:49
1 Answers
0
It exists since the client connects to the server. You can have session and its variables even in a site without authentication.
So its pretty obvious that authentication has nothing to do with it.

P. Jairaj
- 1,033
- 1
- 6
- 8
-
I know the principal always has a value. But automatically when the client connects the first time all session beans are created? – EliuX Jan 25 '16 at 07:05
-
This link will help you: http://docs.oracle.com/javaee/6/tutorial/doc/giplj.html – P. Jairaj Jan 25 '16 at 07:11
-
When client connects to the server, only `HTTP session` is created. The same applies to other kinds of sessions (EJB session, CDI sesssion etc): they are all created automatically always on the first interaction with the client. – G. Demecki Jan 25 '16 at 07:38