This week's book giveaway is in the JDBC forum.
We're giving away four copies of Make it so: Java DB Connections & Transactions and have Marcho Behler on-line!
See this thread for details.
The moose likes JSP and the fly likes Basic page logout design Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Basic page logout design" Watch "Basic page logout design" New topic

Basic page logout design

Abhishek yada

Joined: Mar 11, 2012
Posts: 2

Hi All,

I am learning JSP and Servlet concept. In the process, trying to implement login and logout concept in an Application.

My design is as follows:

User enters his credentials in "login.jsp". The page is redirected to "" which compares the name and password from the database and directs the request object into "homepage.jsp".
In "" i create a HttpSession Object using: HttpSession session = request.getSession(true);

Now to logout of the Application i create a hyperlink in "homepage.jsp" which re-directs the application to logout.jsp. But I am not understanding where to invalidate the session which I created in "".

I tried to session.invalidate() in the "logout.jsp" but 'session' object seems to be out of scope in this "logout.jsp". (editor says "session" object not found). Please tel me how can i implement logout functionality in my Application.


Help me walk..I would do it in the direction of knowledge and wisdom
jhon masco
Ranch Hand

Joined: May 13, 2010
Posts: 98
Here some basic tutorials.
Tutorial 1
Tutorial 2 (special atention to "Session Management in JSP" section).

A basic idea for login would be put the user data from database in a beans and then create a session variable.
Then you could ask for Session variable is empty or No in each jsp page.
For logout just clean the session variable.

Abhishek yada

Joined: Mar 11, 2012
Posts: 2

Thanks for directing me..:)
I agree. Here's the link:
subject: Basic page logout design
It's not a secret anymore!