The webapp module has a JSP file that has a form to accept the input. It also has a servlet that accepts the request parameters and performs the conversion using a core module and provides the response. Now let's see how to get the webapp module in place by performing the following steps:
maven
via the search box, select Maven Module, and click on the Next button as shown in the following screenshot:distance-webapp
and browse to select the parent as Distance-main
.webapp
via the search box, select maven-archetype-webapp, and click on Next to proceed, as shown in the following screenshot:
Field |
Value |
---|---|
Group Id |
|
Version |
|
Package |
|
pom.xml
file of the parent project, we will see how modules are being added to the <module>
tag as follows:<modules> <module>distance-core</module> <module>distance-webapp</module> </modules>
pom.xml
file and add the dependencies for log4j
, servlet, and Tomcat, as shown in the following code; this is also discussed in Chapter 5, Spicing Up a Maven Project, in more detail:<!-- Include servlet API --> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.1.0</version> <scope>provided</scope> </dependency> <!-- For logging purpose could be put in parent POM for modules to inherit --> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.17</version> </dependency> <!-- For tomcat <plugins> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.1</version> </plugin> </plugins>
distance-core
as a dependency since it is used by the webapp to perform the conversion, as shown in the following code:<dependency> <groupId>com.packt.mvneclipse</groupId> <artifactId>distance-core</artifactId> <version>0.0.1-SNAPSHOT</version> <scope>compile</scope> </dependency>
log4j.properties
file to the resources
folder. Refer to the Adding Resources section in Chapter 5, Spicing Up a Maven Project.18.226.181.57