209 Java Web application with HttpSessionListener, ServletContextListener, ServletRequestListener
Автор: tech fort
Загружено: 2020-06-02
Просмотров: 321
Java Web application to demonstrate / apply all 3 listeners ( HttpSessionListener, ServletContextListener, ServletRequestListener ) on 61HttpSessionWithCookiesApp2 (Tutorial No.196):
Operations:
1) To keep track of each request processing duration/time.
2) To keep track of each clients session duration/time.
3) To keep track of the deployment & undeployment timings of web application.
Step 1) Keep 61HttpSessionWithCookiesApp2 web application ready in Server of Previous Tutorial No. 196
Create table:
create table info(name varchar(20), addr varchar(40), age varchar(2),
exp varchar(2), skills varchar(20), city varchar(20), salary varchar(10));
63ServletListenersApp1: (DDS)
----------------------
|--------personal.html
|--------WEB-INF
|--------web.xml
|--------classes
| |--------FirstServlet.java/.class
| |--------SecondServlet.java/.class
| |--------ThirdServlet.java/.class
| |--------MySessListener.java/.class
| |--------MyScListener.java/.class
| |--------MyReqListener.java/.class
|
|---------lib
|----(ojdbcVersion.jar for Oracle or MySqlconnectorVersion.jar for mysql etc.)
Add the *.jar (Mysql)
Step 2) Develop 3 user-defined Listener class under WEB-INF/classes directory of 63ServletListenersApp1 web application.
Step 3) Add MySessListener.java class to classes folder.
Step 4) Add MyScListener.java class to classes folder.
Step 5) Add MyReqListener.java class to classes folder.
Step 6) Configure above 3 listeners classes in web.xml file
Step 7) Test the web application & observe current days log file in tomcat-home/logs/localhost.date.txt file
Test Web Application:
---------------------
http://localhost:8080/63ServletListenersApp1/personal.html
Do observe session id for different browsers
Observe tomcat server console messages
INFO: /furl has taken 8 Milliseconds to processs a request
INFO: /surl has taken 4 Milliseconds to processs a request
INFO: /turl has taken 804 Milliseconds to processs a request
INFO: /63ServletListenersApp1 webapplication is in running mode for 172438 Milliseconds
Do observe the output.
INFO: /furl has taken 12 Milliseconds to processs a request
INFO: /surl has taken 15 Milliseconds to processs a request
INFO: /turl has taken 754 Milliseconds to processs a request
INFO: /63ServletListenersApp1 webapplication is undeployed/reloaded/stopped at Thu Apr 30 13:26:12 IST 2020
INFO: /63ServletListenersApp1 webapplication is in running mode for 316464 Milliseconds
INFO: /63ServletListenersApp1 webapplication id depolyed/restarted/reloaded at Thu Apr 30 13:26:12 IST 2020

Доступные форматы для скачивания:
Скачать видео mp4
-
Информация по загрузке: