Question: How can you count no. of requests coming to struts based web application?
Question: is there any need of developing user defined ActionServlet class?
- Since the front controller ActionServlet traps & takes all the request coming to Struts application you think to place the above said request counting logic in ActionServlet. But we cannot do that work bc3 ActionServlet is a predifend servlet.
- To overcome these problem develop ur own servlet class extending form ActionServlet and configure that servlet class as front controller of struts application.
As shown below:-
Step1:- Develop our own servlet class extending from ActionServlet having counter logic as shown below
Step2:- configure our servlet in web.xml file having extension match url pattern as front controller.
Step4:- read & display application attribute value (ServletContext attribute created in step (1)) from all the jsp programs of Struts application.
In register.jsp / success.jsp / failure.jsp:-
Request count is
- A text file which maintains the entries in the form of key = value pairs is called as properties values.
- The standard principle of s/w industry is donot hardcode any values in your java app. That is changeable in the feature. It is recommended to pass such values to app. Form outside the application by taking the support of property file.
- To make jdbc code as flexible code to modify then it is recommended to take the support of properties file to pass jdbc driver class name, url, dbusor, dbpassword details.
- Struts application can recognize properties files once they are configured in struts configuration file. We use properties file in struts application in the following areas.
1) To maintain presentation logic labels and to make them as flexible to modify.
2) To add I18N (internationalization on struts application) this allows to present labels of the web application in different languages like French, German and etc.
3) To make Jdbc code of struts Action class as flexible code to modify. (Allows the programmer to maintain Jdbc driver class name, url, dbuser, dbpassword details)
4) Can maintain form validation related error messeges.