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 8515045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:02:10+00:00 2026-06-11T05:02:10+00:00

I have a question about realm authentication, where glassfish create more than one http

  • 0

I have a question about realm authentication, where glassfish create more than one http session. Here’s an example

Web.xml:

<security-constraint>
    <web-resource-collection>
      <web-resource-name>AllPages</web-resource-name>
      <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
      <role-name>user</role-name>
    </auth-constraint>
  </security-constraint>
  <login-config>
    <auth-method>BASIC</auth-method>
    <realm-name>FileRealm</realm-name>
  </login-config>
<security-constraint>

glassfish-web.xml:

  <security-role-mapping>
    <role-name>user</role-name>
    <group-name>users</group-name>
  </security-role-mapping>

login.jsp:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Welcome Page</title>
</head>
<body>
<p>You have successfully logged into the application.</p>
<a href="./home.jsp">go to home</a>
</body>
</html>

SessionListener:

@WebListener public class SessionListener implements
HttpSessionListener {

public void sessionCreated(HttpSessionEvent arg0) {

System.out.println(“Session created id:”+arg0.getSession().getId());
}

public void sessionDestroyed(HttpSessionEvent arg0) {

  System.out.println("Session destroyed id:"+arg0.getSession().getId());

}

}

When I authenticate, glassfish create a new session:

INFO: Session created id:29c5d904db0e40b9cfbdac40aa5e

And when I click on “go to home” link or refresh the page, glassfish create another http session:

INFO: Session created id:2a67270137e38c150bf3690e2e46

And I also noticed that glassfish never destroy the first created session.

Thank’s for your help

  • 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-06-11T05:02:12+00:00Added an answer on June 11, 2026 at 5:02 am

    This is probably a Glassfish Bug.
    Try add context.xml to your META-INF directory with this option:

    <?xml version='1.0' encoding='utf-8'?>
    <Context>
    <Valve className="org.apache.catalina.authenticator.BasicAuthenticator"
    changeSessionIdOnAuthentication="false" />
    </Context>
    

    or (in case web form authentication):

    <?xml version='1.0' encoding='utf-8'?>
    <Context>
    <Valve className="org.apache.catalina.authenticator.FormAuthenticator"
    changeSessionIdOnAuthentication="false" />
    </Context>
    

    This should (temporary) solve your problem!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I had a question about C++ destructor behavior, more out of curiosity than anything
I have a question about TSQL function Update. For example, I have a table
I've asked a question about this class before, but here is one again. I've
I have a question about two operations you commonly see in an example Composite
I have a question about how CoCreateInstnace() method locate and create an instance of
I'm following a tutorial. (Real World Haskell) And I have one beginner question about
I have question about parsing in Html helper : I have sth like: @foreach
I have question about clean thory in Python. When: @decorator_func def func(bla, alba): pass
I have question about XSLT1.0. The task is to write out in HTML all
I have question about normalization. Suppose I have an applications dealing with songs. First

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.