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

  • SEARCH
  • Home
  • 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 824103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:03:01+00:00 2026-05-15T03:03:01+00:00

In my web application i neet to check session already exist or not. i

  • 0

In my web application i neet to check session already exist or not.

i want to check this in my servlet and in jsp also.

is there any way to check this.

Thanks

  • 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-15T03:03:01+00:00Added an answer on May 15, 2026 at 3:03 am

    You can test it with HttpServletRequest#getSession(boolean create) with create=false. It will return null if not created yet.

    HttpSession session = request.getSession(false);
    if (session == null) {
        // Session is not created.
    } else {
        // Session is already created.
    }
    

    If you actually want to create the session anyway if it doesn’t exist, then just grab it and test the freshness using HttpSession#isNew():

    HttpSession session = request.getSession();
    if (session.isNew()) {
        // Session is freshly created during this request.
    } else {
        // Session was already created during a previous request.
    }
    

    That was how you would do it in a Servlet. In a JSP you can only test the freshness with help of JSTL and EL. You can grab the session by PageContext#getSession() and then just call isNew() on it.

    <c:if test="${pageContext.session.new}">
        <p>Session is freshly created during this request.</p>
    </c:if>
    

    or

    <p>Session is ${pageContext.session.new ? 'freshly' : 'already'} created.</p>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In web application [asp.net 2008], i am not getting Mobile template option, is there
My web application crashes almost once a week due to not enought memory error.
Our web application basically dynamically generates tables and relations. It also generate indexes on
My web application has started returning 403 errors on PUT requests. However, I'm not
My web-application project (not web-site project) is translated to 15 different languages using the
My web application writes some kind of log during runtime. I don't want to
Context: Web Application - Java, Spring MVC, Spring Security What is not transparent to
This web application is about posting different kind of posts to the web application
My web application generates pdf files and either e-mails or faxes them to our
My web application has a login page that submits authentication credentials via an AJAX

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.