Session lost after each servlet request

If you access the web application via http://localhost then cookies might not be accepted. Thus session could be lost. This happens with netbeans and tomcat after a single logout has been executed.

A solution would be to use http://machinename.localdomain or http://localhost.localdomain or any other local domain if one has been configured.

Alternatively, you can configure localhost.com to your local computer with the following steps:

  1. add line “127.0.0.1     localhost.com” to /etc/hosts (linux). For windows read this article
  2. configure netbeans to use localhost.com instead of localhost

You don’t need to actually configure netbeans to use localhost.com, since you can simply type the path manually but it is better to do so.

 

References:

Modify your hosts file

Session is lost and created as new in every servlet request

 

 

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s