|
| 1 | +About the application |
| 2 | +--------------------- |
| 3 | +This application demonstrates the usage of JavaEE Web Annotations. |
| 4 | + |
| 5 | + |
| 6 | +Contents of the application |
| 7 | +--------------------------- |
| 8 | +1. AccountServlet.java - Demonstrates the @WebServlet and @ServletSecurity annotation. |
| 9 | + |
| 10 | +NOTES: @WebServlet annotation designates the AccountServlet class as a Servlet component. |
| 11 | + The usage of its parameters 'urlPatterns' & 'initParams' can be observed. |
| 12 | + An initialization parameter 'type' is being set to denote the type of the bank account. |
| 13 | + |
| 14 | + @ServletSecurity annotation imposes security constraints on the AccountServlet based on |
| 15 | + the tomcat-users.xml (this code assumes there is a role 'admin' in your tomcat-users.xml) |
| 16 | + |
| 17 | +N.B : To see @ServletSecurity annotation in action, please uncomment the annotation code |
| 18 | + for @ServletSecurity. |
| 19 | + |
| 20 | + |
| 21 | +2. BankAppServletContextListener.java - Demonstrates the @WebListener annotation for denoting a class as a ServletContextListener. |
| 22 | + |
| 23 | +NOTES: Sets a Servlet context attribute ATTR_DEFAULT_LANGUAGE to 'english' on web application start up, |
| 24 | + which can then be used throughout the application. |
| 25 | + |
| 26 | + |
| 27 | +3. LogInFilter.java - Demonstrates the @WebFilter annotation. |
| 28 | + |
| 29 | +NOTES: @WebFilter annotation designates the LogInFilter class as a Filter component. |
| 30 | + It filters all requests to the bank account servlet and redirects them to |
| 31 | + the login page. |
| 32 | + |
| 33 | +N.B : To see @WebFilter annotation in action, please uncomment the annotation code for @WebFilter. |
| 34 | + |
| 35 | + |
| 36 | +4. UploadCustomerDocumentsServlet.java - Demonstrates the @MultipartConfig annotation. |
| 37 | + |
| 38 | +NOTES: @MultipartConfig anotation designates the UploadCustomerDocumentsServlet Servlet component, |
| 39 | + to handle multipart/form-data requests. |
| 40 | + To see it in action, deploy the web application an access the url: http://<your host>:<your port>/JavaEEAnnotationsSample/upload.jsp |
| 41 | + Once you upload a file from here, it will get uploaded to D:/custDocs (assuming such a folder exists). |
| 42 | + |
| 43 | + |
| 44 | +5. index.jsp - This is the welcome page. |
| 45 | + |
| 46 | +NOTES: You can enter a deposit amount here and click on the 'Deposit' button to see the AccountServlet in action. |
| 47 | + |
| 48 | +6. login.jsp - All requests to the AccountServlet are redirected to this page, if the LogInFilter is imposed. |
| 49 | + |
| 50 | +7. upload.jsp - Demonstrates the usage of handling multipart/form-data requests by the UploadCustomerDocumentsServlet. |
| 51 | + |
| 52 | + |
| 53 | +Building and Running the application |
| 54 | +------------------------------------ |
| 55 | +To build the application: |
| 56 | + |
| 57 | +1. Open the project in eclipse |
| 58 | +2. Right click on it in eclispe and choose Run As > Maven build |
| 59 | +3. Give 'clean install' under Goals |
| 60 | +4. This should build the WAR file of the application |
| 61 | + |
| 62 | +To run the application: |
| 63 | + |
| 64 | +1. Right click on the project |
| 65 | +2. Run as > Run on Server |
| 66 | +3. This will start you Tomcat server and deploy the application (Provided that you have configured Tomcat in your eclipse) |
| 67 | +4. You should now be able to access the url : http://<your host>:<your port>/JavaEEAnnotationsSample |
0 commit comments