Search This Blog

part2-servlet assignment and questions

1.) Write an application with 2 Servlet Classes. In one Servlet, get request information from the user and set the collected value as attribute at request and application scopes. Display both attribute values on request of both the Servlets and show the difference between attributes at both levels(scope).
2.) Write a Servlet class, implementing SingleThreadModel and explain the performance degradation occurring with that kind of implementation.
3.) Write a Servlet Class and create new session using the HttpSession object. Display session information to the user, including Session ID, Session creation time and Last Accessed time.
4.) Write an application with a login page,
a. Login Page requires Username and Password for Authentication (matching username and password, already present in DB) and sends request for Home Page.
b. On Authentication, User must be shown the Home Page (servlet) and Session must be created and maintained otherwise show appropriate error message.
c. On the Home Page display 2 links to other Servlets. Similarly other pages must have a link to Home Page.
d. Logout link must be there on all the servlets. User must be given access to all the pages with link to each other, as long as the session is valid. On click of Logout session must be invalidated. If session is destroyed user must be sent to Login Page Again.
5.) In addition to the above question,
a. Use DD configuration to set session time-out value and show how session expires after the specified time.
b. Use setMaxInactiveInterval method to set and overwrite the DD settings and verify the result.
6.) Use getSession(true) method in the above example and check for the condition when the old session is destroyed and new one is created, invalidate the session explicitly by calling invalidate method.
7.) Block (disable) the cookies in the client’s Browser and run the above program.
8.) Use the URL-Rewriting as fall-back mechanism in case the cookies are disabled by the browser with Question (5).
9.) Use Cookie Class object to store username at the Client machine sent by the user in question (5). Display the username retrieved on every page from the cookie object.
10.) Use ServletRequestListener on Home Page (servlet) to create DB connection object to be used for authentication in question(5).Use the HttpSessionEvent to destroy the DB connection object on creation of session in the question (5) .
11.) Write an application with 3 Servlets, 1 Database connection class and a ServletContextListener. Create one Database connection object, before request comes to any one of the 3 Servlet Classes. Use the connection object created, in all the 3 Servlets. 1st Servlet will handle request for emp table, 2nd for dept table and 3rd for salgrade table. Take input from the user in form of drop down menu. Display result in tabular format. Also provide synchronization to the shared database connection object.

No comments:

Post a Comment