This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

session object  RSS feed

 
Maria Tan
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi;

Since session object is default true in JSP page, do i need to call

request.getSessiobn(true) to create a session.

I think i can use session directly. Is that right?

<%
session = request.getSession(true); //should be comment out
session.setAttibute("userName", userName);
%>

By the way, i did false session in my directive.

I was told that if i do not call
session = request.getSession(true);

The session will be locally and i can not see the attibute in my next page, is that right?

Thanks

-Maria
 
Maria Tan
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi;

Sorry i didn't type correct. Here is my question:


Since session object is default true in JSP page, do i need to call

request.getSessiobn(true) to create a session.

I think i can use session directly. Is that right?

<%
session = request.getSession(true); //should be comment out
session.setAttibute("userName", userName);
%>

By the way, i didn't false session in my directive.

I was told that if i use session hidden in JSP, it will be locally and i can not get the attibute setting in my session in my next page. But if i call

session = request.getSession(true);

The session will be global. Then i can get attribute. Is this true?

Thanks in advance

-Maria
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66188
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Maria Tan:
Sorry i didn't type correct. Here is my question:
If you make a posting error, you can edit your post by clicking the icon.
 
Marimuthu Madasamy
Ranch Hand
Posts: 72
Java Monad Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you dont need to make a call to request.getSession(true or false) inside JSP since implicit 'session' object is available by default. However 'session' attribute of 'page' directive matters.

<%@ page session="false" %> //no session object

by default, session="true"
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!