GeezerVison is showing github.com — mvn package working · padminipc/demo-java@615a317
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboard +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +target |
Collapse file
Copy file name to clipboardExpand all lines: README.md +1-1Lines changed: 1 addition & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -10,7 +10,7 @@ Simple java project demos how to build a war file to be deployed on a Tomcat ser |
10 | 10 |
|
11 | 11 | ## Initial Generation |
12 | 12 |
|
13 | | -The initial files and project structure was generated with the `mvn archetype:generate` command. Note, you do not have to run the command it is just noted here for posterity. |
| 13 | +The initial files and project structure was generated with the `mvn archetype:generate` command. Note, you do not have to run the command it is just noted here for posterity. More info: [Creating a webapp](https://maven.apache.org/plugins-archives/maven-archetype-plugin-1.0-alpha-7/examples/webapp.html) and [Introduction to the Standard Directory Layout](https://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html). |
14 | 14 |
|
15 | 15 | ``` sh |
16 | 16 | mvn archetype:generate \ |
|
Collapse file
Copy file name to clipboardExpand all lines: pom.xml +30-5Lines changed: 30 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
5 | 5 | <artifactId>demo</artifactId> |
6 | 6 | <packaging>war</packaging> |
7 | 7 | <version>1.0-SNAPSHOT</version> |
8 | | - <name>demo Maven Webapp</name> |
9 | | - <url>http://maven.apache.org</url> |
| 8 | + <name>Demo Maven Webapp</name> |
| 9 | + <url>https://github.com/tongueroo/demo-java</url> |
| 10 | + <build> |
| 11 | + <finalName>demo</finalName> |
| 12 | + <sourceDirectory>src</sourceDirectory> |
| 13 | + <plugins> |
| 14 | + <plugin> |
| 15 | + <artifactId>maven-compiler-plugin</artifactId> |
| 16 | + <version>3.7.0</version> |
| 17 | + <configuration> |
| 18 | + <source>1.8</source> |
| 19 | + <target>1.8</target> |
| 20 | + </configuration> |
| 21 | + </plugin> |
| 22 | + <plugin> |
| 23 | + <artifactId>maven-war-plugin</artifactId> |
| 24 | + <version>3.0.0</version> |
| 25 | + </plugin> |
| 26 | + </plugins> |
| 27 | + </build> |
10 | 28 | <dependencies> |
11 | 29 | <dependency> |
12 | 30 | <groupId>junit</groupId> |
13 | 31 | <artifactId>junit</artifactId> |
14 | 32 | <version>3.8.1</version> |
15 | 33 | <scope>test</scope> |
16 | 34 | </dependency> |
| 35 | + <dependency> |
| 36 | + <groupId>log4j</groupId> |
| 37 | + <artifactId>log4j</artifactId> |
| 38 | + <version>1.2.17</version> |
| 39 | + </dependency> |
| 40 | + <dependency> |
| 41 | + <groupId>javax.servlet</groupId> |
| 42 | + <artifactId>javax.servlet-api</artifactId> |
| 43 | + <version>3.1.0</version> |
| 44 | + </dependency> |
17 | 45 | </dependencies> |
18 | | - <build> |
19 | | - <finalName>demo</finalName> |
20 | | - </build> |
21 | 46 | </project> |
Collapse file
Copy file name to clipboard +26Lines changed: 26 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Import required java libraries |
| 2 | +import java.io.*; |
| 3 | +import javax.servlet.*; |
| 4 | +import javax.servlet.http.*; |
| 5 | + |
| 6 | +// Extend HttpServlet class |
| 7 | +public class Hello extends HttpServlet { |
| 8 | + |
| 9 | + private String message; |
| 10 | + |
| 11 | + public void init() throws ServletException { |
| 12 | + // Do required initialization |
| 13 | + message = "Hello World"; |
| 14 | + } |
| 15 | + |
| 16 | + public void doGet(HttpServletRequest request, HttpServletResponse response) |
| 17 | + throws ServletException, IOException { |
| 18 | + |
| 19 | + // Set response content type |
| 20 | + response.setContentType("text/html"); |
| 21 | + |
| 22 | + // Actual logic goes here. |
| 23 | + PrintWriter out = response.getWriter(); |
| 24 | + out.println("<h1>" + message + "</h1>"); |
| 25 | + } |
| 26 | +} |
Collapse file
Copy file name to clipboardExpand all lines: src/main/webapp/WEB-INF/web.xml +19-1Lines changed: 19 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
|
3 | 3 | "http://java.sun.com/dtd/web-app_2_3.dtd" > |
4 | 4 |
|
5 | 5 | <web-app> |
6 | | - <display-name>Archetype Created Web Application</display-name> |
| 6 | + <display-name>demo java web app</display-name> |
| 7 | + <welcome-file-list> |
| 8 | + <welcome-file>index.html</welcome-file> |
| 9 | + <welcome-file>index.htm</welcome-file> |
| 10 | + <welcome-file>index.jsp</welcome-file> |
| 11 | + <welcome-file>default.html</welcome-file> |
| 12 | + <welcome-file>default.htm</welcome-file> |
| 13 | + <welcome-file>default.jsp</welcome-file> |
| 14 | + </welcome-file-list> |
| 15 | + |
| 16 | + <servlet> |
| 17 | + <servlet-name>Hello</servlet-name> |
| 18 | + <servlet-class>Hello</servlet-class> |
| 19 | + </servlet> |
| 20 | + <servlet-mapping> |
| 21 | + <servlet-name>Hello</servlet-name> |
| 22 | + <url-pattern>/Hello</url-pattern> |
| 23 | + </servlet-mapping> |
| 24 | + |
7 | 25 | </web-app> |