File tree Expand file tree Collapse file tree 5 files changed +121
-0
lines changed
Expand file tree Collapse file tree 5 files changed +121
-0
lines changed Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <classpath >
3+ <classpathentry kind =" src" path =" src/main/java" including =" **/*.java" />
4+ <classpathentry kind =" src" path =" src/main/resources" excluding =" **/*.java" />
5+ <classpathentry kind =" output" path =" target/classes" />
6+ <classpathentry kind =" con" path =" org.eclipse.jdt.launching.JRE_CONTAINER" />
7+ <classpathentry kind =" var" path =" M2_REPO/javax/javaee-api/7.0-b82/javaee-api-7.0-b82.jar" />
8+ </classpath >
Original file line number Diff line number Diff line change 1+ <project xmlns =" http://maven.apache.org/POM/4.0.0" xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
2+ xsi : schemaLocation =" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
3+
4+
5+ <modelVersion >4.0.0</modelVersion >
6+
7+ <groupId >com.hmkcode</groupId >
8+ <artifactId >webservlet-annotation</artifactId >
9+ <version >1.0-SNAPSHOT</version >
10+ <packaging >war</packaging >
11+
12+ <name >webservlet-annotation</name >
13+
14+ <dependencies >
15+
16+ <dependency >
17+ <groupId >javax</groupId >
18+ <artifactId >javaee-api</artifactId >
19+ <version >7.0-b82</version >
20+ <scope >provided</scope >
21+ </dependency >
22+ </dependencies >
23+
24+ <build >
25+ <plugins >
26+ <plugin >
27+ <groupId >org.apache.maven.plugins</groupId >
28+ <artifactId >maven-compiler-plugin</artifactId >
29+ <version >2.3.2</version >
30+ <configuration >
31+ <source >1.6</source >
32+ <target >1.6</target >
33+ </configuration >
34+ </plugin >
35+ <plugin >
36+ <groupId >org.eclipse.jetty</groupId >
37+ <artifactId >jetty-maven-plugin</artifactId >
38+ <version >9.0.3.v20130506</version >
39+ </plugin >
40+
41+ </plugins >
42+ </build >
43+
44+ </project >
Original file line number Diff line number Diff line change 1+
2+ package com .hmkcode ;
3+
4+ import java .io .IOException ;
5+ import java .io .PrintWriter ;
6+
7+ import javax .servlet .annotation .WebServlet ;
8+ import javax .servlet .http .HttpServlet ;
9+ import javax .servlet .http .HttpServletRequest ;
10+ import javax .servlet .http .HttpServletResponse ;
11+
12+
13+ @ WebServlet (urlPatterns = {"/servlet" })
14+ public class MyServlet extends HttpServlet {
15+
16+
17+ private static final long serialVersionUID = 1L ;
18+
19+ @ Override
20+ protected void doGet (HttpServletRequest request , HttpServletResponse response ) {
21+ response .setContentType ("text/html;charset=UTF-8" );
22+ try {
23+ PrintWriter out = response .getWriter ();
24+ out .println ("<h2>Hello @WebServlet</h2>" );
25+ } catch (IOException ioe ) {
26+
27+ }
28+ }
29+
30+
31+ }
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <web-app xmlns =" http://java.sun.com/xml/ns/javaee"
3+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
4+ xsi : schemaLocation =" http://java.sun.com/xml/ns/javaee
5+ http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
6+ version =" 3.0" >
7+
8+ <display-name >webservlet-annotation</display-name >
9+ <welcome-file-list >
10+ <welcome-file >index.jsp</welcome-file >
11+ </welcome-file-list >
12+
13+ <!-- <servlet> -->
14+ <!-- <servlet-name>MyServlet</servlet-name> -->
15+ <!-- <servlet-class>com.hmkcode.MyServlet</servlet-class> -->
16+ <!-- </servlet> -->
17+
18+ <!-- <servlet-mapping> -->
19+ <!-- <servlet-name>MyServlet</servlet-name> -->
20+ <!-- <url-pattern>/servlet</url-pattern> -->
21+ <!-- </servlet-mapping> -->
22+ </web-app >
Original file line number Diff line number Diff line change 1+
2+ <%@page contentType =" text/html" pageEncoding =" UTF-8" %>
3+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
4+ "http://www.w3.org/TR/html4/loose.dtd" >
5+
6+ <html >
7+ <head >
8+ <meta http-equiv =" Content-Type" content =" text/html; charset=UTF-8" >
9+ <title >@WebServlet</title >
10+ </head >
11+ <body >
12+ <h1 >@WebServlet</h1 >
13+
14+ Test <a href =" servlet" >MyAnnotatedServlet</a ><br />
15+ </body >
16+ </html >
You can’t perform that action at this time.
0 commit comments