• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

page attribute tag for session?

 
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I am learning about sessions and I want to know what session="true" or session="false" is for and if it is required to maintain a session state.

<%@page language="java" session="true" %>

Do I need this in every page where I use a session varible a cross many pages?

Thanks for any help
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This determines whether the page will participate in the session or not. It defaults to true. I've never put this directive on a JSP page in my 10 years of using JSP.
 
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
as you know JSP's are translated to servlets and then the servlets are compiled ... bla bla bla (the life cycle of a JSP file)

and in each JSP there are some implicit objects that you can use such as (session, request, response, out ... etc), those objects are created by default in Servlet that gets generated from the JSP. and if you look in the code generated from the translation of your JSP file you should see somewhere this line of code



which creates the JSP implicit "session" object that you can use in your page, if in someway you don't want that that object gets initialized you set the session parameter in the page directive to false so it will not be generated. to clarify more this point if you try to write the following expression in a JSP (test.jsp) :



and you deploy your application and request the test.jsp you will always get a true.

hope you got it ;)

(peace)
 
Sam Doder
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok , so it is only if I wanted to exclude a page from being part of a session.

Just curious
if I had a page with
<%@page language="java" session="false" %>

Then I do try to use session varable what will it do ?

And could I have to different sessions at the same time over my jsp pages?

Thanks
 
Bear Bibeault
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) Try it and see.

2) No.
 
Sam Doder
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok , I am at work .

Working for the first time with sessions my boss wants me to figure out a problem with this session stuff.

What is happening is we are using jetty application server.

Whenever we change the password. And try to login in with the new password it won't let us.
We still have to use the old password. Until we shutdown the server an restart it.
I know the password is being stored properly in the mysql database when the use click save new password button.

The problem is when he clicks log out and goes back into the login page and types the new password it won't work. But the old password works until we shutdown the server. How is this even possible the old password isn't even in the data base.

Is something caching the old password I am using <form id="form-login" name="login" method="post" action="j_security_check" >
could this be caching the old password or doing something werid. I would think it would be using the current thing stored in the database?

And on top of all this my boss is pushing me to figure this out. AAAAAAAAAAA H
 
Sam Doder
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Figured it out for anybody that wants to know or is working with jetty application server.

You must set the cachetime = 0 by default it is 300.
This is why I would get an error even though the password was different in the database.

Also you obviously need session.invalidate() on your logout page hope this helps somebody.
With my similar problem it to all day to figure it out :lol:

 
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
jsp has been into market since 2004
 
Bear Bibeault
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

RaviNada Kiran wrote:jsp has been into market since 2004

Incorrect. I was using an early version of JSP (0.9.2 or something like that, where the <jsp:userBean> tag was still <bean>) in 1998. Please go roll your eyes at someone else.
 
We noticed he had no friends. So we gave him this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic