Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3331506
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:35:28+00:00 2026-05-17T23:35:28+00:00

I have using jsp technology in my project.I want to do session tracking in

  • 0

I have using jsp technology in my project.I want to do session tracking
in my login form.
After logout when i press back button it should be show
session is expired.Please help me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T23:35:28+00:00Added an answer on May 17, 2026 at 11:35 pm

    You don’t need to do it manually. The servletcontainer will do it for you. You can access the tracked session by HttpServletRequest#getSession(). All you need to do is to put the logged-in user as a session attribute.

    request.getSession().setAttribute("user", user);
    

    Let the rest of your code intercept on that. You usually use a Filter for this.

    if (request.getSession().getAttribute("user") == null) {
        // Not logged in. Redirect to login page.
        response.sendRedirect("login.jsp");
    } else {
        // Logged in. Just continue request.
        chain.doFilter(request, response);
    }
    

    When you invoke the logout, just remove the user from the session.

    request.getSession().removeAttribute("user");
    

    The servletcontainer will manage the session expiration as well. When it expires, then the HttpSession will simply be trashed, including all of its attribtues.

    As to the back button question, just instruct the client to not cache the response so that it’s forced to fire a brand new request which would then be passed through the Filter. This client instruction needs to happen by setting the response headers accordingly. That could be done in a Filter as well.

    response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
    response.setHeader("Pragma", "no-cache"); // HTTP 1.0.
    response.setDateHeader("Expires", 0); // Proxies.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In a web project using jsp, I have following requirement Upload a file (say
I have form and form text field which generates dynamically using JSP. And I'm
I am developing a java webapp, using jsp/jquery/ejb/jboss. I have a web-form that enables
I have created a chart using JFreeChart inside a JSP. I want to render
I have a web application built using jsp/servlets.The web application session is set to
I'm writing a website using JSP. I want to have the website available in
I'm using jsp and a servlet to do this. I have a contact form
I am using jsp for a web based project. i want to remove all
I am using jsp and struts2, and I have the following scenario: <s:form> <s:hidden
Im trying to compile this project h__p://ross-warren.co.uk/my-twitter-clone-using-jsp-and-cassandra/ I have downloaded it, and spend almost

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.