How does Session handling works in Servlet environment
Carvia Tech | December 04, 2019 | 1 min read | 79 views
There are multiple ways to handle session by a servlet framework. For example following methods can be used,
-
Storing Cookies on the client side
-
URL Rewriting
-
Hidden form fields
Servlets use cookies as the default mechanism for session tracking, but in case cookies are disabled on the client, Server can use URL re-writing for achieving the same.
When server calls request.getSession(true), then server generates and sends JSESSIONID back to the client for all future session references. JSESSIONID will then be stored by the client and sent back to the server using any of the above mentioned mechanisms.
To ensure that your Servlets support servers that use URL rewriting to track sessions, you must pass all the URL’s used in your servlet through the HttpServletResponse.encodeURL() method
Top articles in this category:
- Feign exception handling in Spring Cloud
- How to prevent duplicate form submission in Spring MVC
- Prevent Lost Updates in Database Transaction using Spring Hibernate
- Synechron Java Interview Questions
- Disable SSL validation in Spring RestTemplate
- Feign Client Logging and connection timeout
- Table backed global counter in spring hibernate
Find more on this topic:
Subscribe to Interview Questions
Recommended books for interview preparation:
Similar Posts
- Elasticsearch with Spring Boot + Spring Data
- Download a file using Spring RestTemplate
- Slack Webhook Message from Spring Boot
- Spring Webclient multipart file upload
- Dialoglfow fulfillment with Spring Boot
- Spring Boot WebClient Basic Authentication
- SendGrid Attachments with Spring Boot
- Sendgrid Dynamic Templates with Spring Boot
- Redis rate limiter in Spring Boot
- Custom TTL for Spring data Redis Cache