BAEL-9148 Fix Java EE Annotations Project

- Removed JavaEEAnnotationsSample project from inside src/main/java/com/baeldung/javaeeannotations folder of jee-7 module
- Moved sources and jsps to jee-7 main module
This commit is contained in:
Dhawal Kapil 2018-09-30 19:31:56 +05:30
parent 4c1250c76f
commit 5c36405c1f
12 changed files with 6 additions and 155 deletions

View File

@ -6,3 +6,4 @@
- [A Guide to Java EE Web-Related Annotations](http://www.baeldung.com/javaee-web-annotations)
- [Introduction to Testing with Arquillian](http://www.baeldung.com/arquillian)
- [Securing Java EE with Spring Security](http://www.baeldung.com/java-ee-spring-security)
- [A Guide to Java EE Web-Related Annotations](https://www.baeldung.com/javaee-web-annotations)

View File

@ -130,7 +130,7 @@
<artifactId>maven-war-plugin</artifactId>
<version>${maven-war-plugin.version}</version>
<configuration>
<warSourceDirectory>webapp</warSourceDirectory>
<warSourceDirectory>src/main/webapp</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>

View File

@ -1,4 +1,4 @@
package com.baeldung.javaeeannotations.JavaEEAnnotationsSample.src.main.java.com.baeldung.javaeeannotations;
package com.baeldung.javaeeannotations;
import java.io.IOException;
import java.io.PrintWriter;

View File

@ -1,4 +1,4 @@
package com.baeldung.javaeeannotations.JavaEEAnnotationsSample.src.main.java.com.baeldung.javaeeannotations;
package com.baeldung.javaeeannotations;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

View File

@ -1,76 +0,0 @@
About the application
---------------------
This application demonstrates the usage of JavaEE Web Annotations.
Contents of the application
---------------------------
1. AccountServlet.java - Demonstrates the @WebServlet and @ServletSecurity annotation.
NOTES: @WebServlet annotation designates the AccountServlet class as a Servlet component.
The usage of its parameters 'urlPatterns' & 'initParams' can be observed.
An initialization parameter 'type' is being set to denote the type of the bank account.
@ServletSecurity annotation imposes security constraints on the AccountServlet based on
the tomcat-users.xml.
 
This code assumes that your tomcat-users.xml looks as follows:
<role rolename="Admin"/>
<role rolename="Member"/>
<role rolename="Guest"/>
<user username="Annie" password="admin" roles="Admin, Member, Guest" />
<user username="Diane" password="coder" roles="Member, Guest" />
<user username="Ted" password="newbie" roles="Guest" />
 
N.B : To see @ServletSecurity annotation in action, please uncomment the annotation code
for @ServletSecurity.
2. BankAppServletContextListener.java - Demonstrates the @WebListener annotation for denoting a class as a ServletContextListener.
NOTES: Sets a Servlet context attribute ATTR_DEFAULT_LANGUAGE to 'english' on web application start up,
which can then be used throughout the application.
3. LogInFilter.java - Demonstrates the @WebFilter annotation.
NOTES: @WebFilter annotation designates the LogInFilter class as a Filter component.
It filters all requests to the bank account servlet and redirects them to
the login page.
N.B : To see @WebFilter annotation in action, please uncomment the annotation code for @WebFilter.
4. UploadCustomerDocumentsServlet.java - Demonstrates the @MultipartConfig annotation.
NOTES: @MultipartConfig anotation designates the UploadCustomerDocumentsServlet Servlet component,
to handle multipart/form-data requests.
To see it in action, deploy the web application an access the url: http://<your host>:<your port>/JavaEEAnnotationsSample/upload.jsp
Once you upload a file from here, it will get uploaded to D:/custDocs (assuming such a folder exists).
5. index.jsp - This is the welcome page.
NOTES: You can enter a deposit amount here and click on the 'Deposit' button to see the AccountServlet in action.
6. login.jsp - All requests to the AccountServlet are redirected to this page, if the LogInFilter is imposed.
7. upload.jsp - Demonstrates the usage of handling multipart/form-data requests by the UploadCustomerDocumentsServlet.
Building and Running the application
------------------------------------
To build the application:
1. Open the project in eclipse
2. Right click on it in eclispe and choose Run As > Maven build
3. Give 'clean install' under Goals
4. This should build the WAR file of the application
To run the application:
1. Right click on the project
2. Run as > Run on Server
3. This will start you Tomcat server and deploy the application (Provided that you have configured Tomcat in your eclipse)
4. You should now be able to access the url : http://<your host>:<your port>/JavaEEAnnotationsSample

View File

@ -1,52 +0,0 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.baeldung.javaeeannotations</groupId>
<artifactId>JavaEEAnnotationsSample</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>JavaEEAnnotationsSample</name>
<description>JavaEEAnnotationsSample</description>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<warSourceDirectory>src/main/webapp</warSourceDirectory>
<warName>SpringFieldConstructorInjection</warName>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<finalName>JavaEEAnnotationsSample</finalName>
</build>
</project>

View File

@ -1,10 +0,0 @@
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1">
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>default</realm-name>
</login-config>
</web-app>

View File

@ -1,12 +0,0 @@
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Login</title>
</head>
<body>
Login Here...
</body>
</html>

View File

@ -1,4 +1,4 @@
package com.baeldung.javaeeannotations.JavaEEAnnotationsSample.src.main.java.com.baeldung.javaeeannotations;
package com.baeldung.javaeeannotations;
import java.io.IOException;

View File

@ -1,4 +1,4 @@
package com.baeldung.javaeeannotations.JavaEEAnnotationsSample.src.main.java.com.baeldung.javaeeannotations;
package com.baeldung.javaeeannotations;
import java.io.IOException;
import java.io.PrintWriter;