EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 600+ Courses All in One Bundle
  • Login
Home Software Development Software Development Basics Servlet Session Management
Secondary Sidebar
Network Security Tutorial
  • Advanced
    • Cryptosystems
    • Configuring DHCP Server
    • Encapsulation Security Payload
    • Block Cipher modes of Operation
    • TCP/IP Model
    • Ad hoc network types
    • Types of Network
    • Types of Network Devices
    • Types of Network Topology
    • Types of Intrusion Prevention System
    • Types of Proxy Servers
    • Types of Websites
    • Typesof NAT
    • Mobile IP
    • IP Spoofing Tools
    • Career in Automobile Design
    • What is TFS
    • What is NAT
    • What is OSI Model
    • Data Link Layer OSI Model
    • What is Cross Site Scripting
    • Applications of Sensors
    • ARP Packet Format
    • What is Packet Switching?
    • Packet Switching Advantages
    • Asymmetric Information
    • Autoencoders
    • What is FTP Server?
    • IPS Tools
    • OpenSSL tool
    • IPv4 Header Format
    • IPv6 Header Format
    • Authentication Header
    • Authentication Types
    • Kerberos
    • Network Mapper
    • Network Scanning Tools
    • Network Mapping Tools
    • Network Access Control
    • Vulnerability Assessment Tools
    • Network Sniffer
    • Networking Commands
    • Networking Devices
    • Networking Strategies
    • Digital Certificate
    • What is a Digital Signature?
    • Digital Signature Softwares
    • Digital Signature Types
    • Digital Signature vs Digital Certificate
    • PKCS
    • Ethernet uses
    • HTTP Uses
    • Servlet Session Management
    • What is FTP
    • FTP Commands
    • What is MIME?
    • What is Smart Card?
    • Networking Ports
    • Mutual Authentication
    • Password Authentication
    • Data Masking
    • Authentication Tokens
    • Biometric Authentication
    • What is IP?
    • IPSec
    • Secure Electronic Transaction
    • What is CIDR
    • Static Binding and Dynamic Binding
    • What is SSL
    • PKIX
    • Public Key Infrastructure
    • What is Wireshark
    • Use of Wireshark
    • Daisy Chain Topology
    • Markov Logic Network
    • Security engineering
    • SNMP Monitoring Tools
    • Network Analysis Tools
    • Server Monitoring Tools
    • Network Discovery Tools
    • Network Management Tool
    • SIEM Tools
    • OSINT Tools
    • Multiple Ping Tool
  • Basics
    • Security Consultant Definition
    • Security Policies
    • What is Network Security
    • What is Data Security?
    • What is Cryptography
    • Cryptography Techniques
    • Cryptography Tools
    • Data Security Techniques and Privacy
    • Phishing? Tools
    • Ransomware decryption tools
    • OpenSSH
    • Authorization Types
    • Digital Signature Cryptography
    • PuTTY Alternatives
    • Digital Signature Uses
    • Ransomware types
    • Java Cryptography
    • Basics of Cybersecurity
    • What is Network Topology
    • Algorithms and Cryptography
    • HTTP Methods
    • Authentication methods
    • Security Technologies
    • Security Architecture
    • Email Security Gateways
    • Network Monitoring Tools
    • Network Analysis
    • Types of ddos Attack
    • Network Topologies
    • What is a Physical Address?
    • Packet Switching Advantages and Disadvantages
    • Logical Address
    • What is Storage Area Network?
    • Mobile Ad Hoc Network
    • What is Computer Networks?
    • Security Principles
    • Data Integrity
    • Subnetting and Supernetting
    • What is Remote Access?
    • OpenSSL Version
    • OpenSSH version
    • Port Forwarding
    • Privileged Access Management Tools
    • Security Testing Types
  • Protocols
    • What is TCP Protocol
    • What is TCP/IP
    • How do IP Addresses Work?
    • POP Protocol
    • CentOS Change IP Address
    • IPSec protocol
    • Application layer protocols
    • Data Link Layer Protocol
    • Routing Protocols Types
    • Spoofing Types
    • What is Telnet
    • What is TFTP
    • What is DHCP
    • DHCP Advantages
    • What is SFTP
    • Address Resolution Protocol
    • ISAKMP Protocol
    • Internet Control Message Protocol
    • Simple Mail Transfer Protocol
    • Internet Security Protocols
    • RIP Protocol
    • SMTP Protocol
    • User Datagram Protocol
    • Data Link Layer
    • Data Link Layer Services
    • Network Layer
    • Transport Layer Protocols
    • What Is Networking Protocols
    • TFTP
    • What is ARP
    • Basic Fundamental Of Networking
    • What is IPv4
    • What is IPv6
    • CIFS Protocol
    • What is SMB?
    • What is SIEM
    • What is Subnet?
    • Port Forwarding Software
    • OSPF Router Types
    • What is EIGRP
    • What is LLDP?
  • Routing
    • What is Router
    • Types of Routers
    • Dynamic Routing
    • Routing Algorithms
    • Routing Protocol
    • What is Routing
    • What is Static Routing
    • Important Types of DNS Servers (Powerful)
  • Attacks
    • Types of Network Attacks
    • What is Trojan Horse Virus
    • What is DOS
    • Types of DOS Attacks
    • DDos Attack Mitigation
    • Ransomware Attack
    • Types of Cyber Attack
    • What is a Brute Force Attack
    • What is a Phishing Attack
    • What is Cyber Attack
    • What is DDoS Attack
    • What is Man In The Middle Attack
    • What is Man In The Middle Attack
    • What is Ransomware
    • What is Pharming
    • What is Phishing
    • What is CSRF
    • DNS Amplification Attack
    • Denial of Service Attack
  • Algorithm
    • IDEA Algorithm
    • MD5 Algorithm
    • Symmetric Algorithms
    • Diffie Hellman Key Exchange Algorithm
    • Digital Signature Algorithm
    • Encryption Algorithm
    • Advanced Encryption Standard
    • Asymmetric Encryption
    • ElGamal Encryption
    • HMAC
    • DES Algorithm
    • Brute Force Algorithm
    • SHA Algorithm
    • RSA Algorithm
    • What is Digital Certificate?
    • Certificate Revocation
    • RC5
  • Encryption/ Decryption
    • Encryption process
    • Public Key Encryption
    • Symmetric Key Encryption
    • What is Encryption
    • What is Decryption
    • Types of Cipher
    • Transposition Techniques
    • What is Steganography
    • One Time Pad
    • Steganography Techniques
  • Hosting
    • Types of Web Hosting
    • Web Documents
    • Free Web Hosting Sites
    • What is Hosting
    • What is VPS Hosting
    • What is Web Hosting
    • Types of Domain
    • VPN Applications for PC
    • Why we use VPN?
    • VPN Tunneling
    • What is Virtual Host?
    • Virtual Private Network
  • Firewalls
    • What is a Firewall?
    • Firewall Architecture
    • Types of Firewalls
    • Firewall Devices
    • Firewall Security
    • Firewall Uses
  • Interview Questions
    • Network Security Interview Questions
    • Networking Interview Questions
    • EIGRP Interview Questions

Servlet Session Management

Servlet Session Management

Introduction to Servlet Session Management

Servlet Session Management is a mechanism in Java used by Web container to store session information. Session tracking is a way to manage the data of a user, this is known as session management in servlet. Session in Java are managed through different ways, such as, HTTP Session API, Cookies, URL rewriting, etc. Session management or tracking is an important feature of modern websites that allows server to remember clients. Before entering into this topic, session is a conversation between server and client, it contains series of continuous requests and responses.

Why is Session Maintained?

When there are continuous request and responses from same client to server, so the server cannot identify from which client are requests being sent. As HTTP is a Stateless protocol.

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

Although there is an advantage of being stateless, some requests enforce in maintaining state in order to maintain proper functionality.

Session Management/ Tracking Methods

  • User Authorization: It is one way where user provides Username and password or any authentication credentials from login and then these are passed via server and client to maintain the servlet session. It is not much effective as this does not work if same user is logged from different browsers.
  • URL rewriting: User can append session identifier parameter with every request and response to keep track of session. It is tedious as user needs to keep track of parameter in each response and to make sure, it does not clash with other parameters.
  • Hidden Fields: User has access to create unique field in HTML which is hidden, when user starts navigating, user will be able to set the value uniquely to customer and have track over the session. This method is not used with links as this needs form being submitted each time there is a request made from client to the server with any hidden fields. It is not much secure as user can get this hidden field value from source code and use to hack sessions.
  • Session Tracking API: It is built on top of all other Tracking methods. This type of session tracking is used for developers to minimize overhead of session tracking. Major disadvantage is that most of the time, user need not have to track session, but need to store some data in the session that can be used in future requests.
  • Cookies: Cookie is a key value pair of information sent by server to browsers. It is the most used technology for session tracking. Cookie is a smallest piece of information sent by the web server in head tag and is stored as browser cookie. When there is a further request, cookies get added to the requested header and can be utilized to keep track of servlet session. If customer disables cookie, servlet session with cookie will not work.
  • Two types in Cookies:
    • Non-persistent Cookie: It is valid only for single session and is removed each time when browser gets closed.
    • Persistent Cookie: It is valid for multiple sessions and is removed only when user logs out but not when browsers get closed.
  1. HTTP and SSL: Browsers that support Secure Socket Layer communication use SSL support via HTTPS to generate unique session key as part of encrypted conversation. Modern sites like e-commerce, ticket booking, Internet banking, etc., use HTTPs to securely transfer data and manage session.

How to Create New Session Object and Enable?

  • Make a new session object.

request.getSession() is the method that creates new session object. Container generates new session ID for present session and sends back to client.

HttpSession session = request.getSession();

  • Store information in session object.

Session objects are just hash tables that store user objects and associate user object with keys.

  • Look up for information associated with Servlet.

If session already exists, session code tells container to extract ID from cookies. Container uses this ID as key to search table of previously created HttpSession objects. If there is a session found, user can access that session by getAttribute(‘key’) method.

Key Method Used in HTTPSession

  • isNew(): Returns true is user does not know about the session. If cookies are disabled, then session is new.
  • getId(): Returns string that contains unique identifier that is assigned to this session. Is used while using URL rewriting the session.
  • getAttribute(): Returns the object bound in present session.
  • setAttribute(): Binds object to present session, uses specified name.
  • invalidate(): Expires current session and unbinds the object binded
  • setMaxInactiveInterval(): Specifies time between client requests before servlet invalidates session. Negative time indicates session shouldn’t timeout.

With this we shall conclude the topic ‘Servlet session Management’. We have seen what Servlet Session Management means and the types of Session tracking or management methods such as User Authorization, Hidden fields, HTTPS or SSL, URL Rewriting, Cookies, and Session tracking API. We have also seen How to create Session Object and enable it, listed out some methods applicable to session objects. Thanks! Happy Learning!!

Recommended Articles

This is a guide to Servlet Session Management. Here we also discuss the introduction and why is session maintained? along with key method used in HTTPSession. You may also have a look at the following articles to learn more –

  1. Flask HTTPS
  2. Lua HTTP
  3. HTTP Caching
  4. HTTP Methods
Primary Sidebar
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Java Tutorials
  • Python Tutorials
  • All Tutorials
Certification Courses
  • All Courses
  • Software Development Course - All in One Bundle
  • Become a Python Developer
  • Java Course
  • Become a Selenium Automation Tester
  • Become an IoT Developer
  • ASP.NET Course
  • VB.NET Course
  • PHP Course

ISO 10004:2018 & ISO 9001:2015 Certified

© 2023 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA Login

Forgot Password?

By signing up, you agree to our Terms of Use and Privacy Policy.

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more