Nearby lessons
19 of 34Servlet - Session Management (URL Rewriting)
- Understand Demo Program for session management by url rewriting
- See complete working code examples
Session Management (URL Rewriting) is an essential part of the Java Servlet technology. This lesson explains Demo Program for session management by url rewriting, SessionServlet1.java and SessionServlet2.java with complete, runnable code examples, clear step-by-step explanations, and common mistakes to avoid.
Demo Program for session management by url rewriting
login.html:
Demo Program for session management by url rewriting
SessionServlet1.java
SessionServlet2.java
session5
|-login.html
|-WEB-INF
|-classes
|-SessionServlet1.class
|-SessionServlet2.class
Advantages of URL Rewriting:
There is no chance of disabling url rewriting technique. Hence it will work always.
Limitations of URL Rewriting:
1.It is very difficult to rewrite all urls to append session information.Hence it is the most painful
technique.
2.URL Rewriting will work only for dynamic documents.
Session Management by using Hidden Form Fields
It is not official technique from SUN Micro Systems.It is just Programmer's trick to remember client
information.
In case of Hidden Form Field a hidden (invisible) textfield is used for maintaining the state of an
user.
In such case, we store the information in the hidden field, which is required for future purpose.
We can declare hidden form field as follows..
<input type="hidden" name="uname" value="chitu">
Advantage of Hidden Form Field
It will always work whether cookie is disabled or not.
Disadvantage of Hidden Form Field:
- It is maintained at server side.
- Extra form submission is required on each page.
- Session information should be text data
- Key ideas of Servlet - Session Management (URL Rewriting) explained simply
- Ready-to-use code examples
- Exam-style questions at the end