8000 GitHub - zhouguoqing917/example: api
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

zhouguoqing917/example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cd example mkdir -p src/main/java/org/example Creating the HelloWorld Class vim src/main/java/org/example/HelloWorld.java

(1)#java package org.example;

import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;

public class HelloServlet extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); response.setStatus(HttpServletResponse.SC_OK); response.getWriter().println("

Hello Servlet

"); response.getWriter().println("session=" + request.getSession(true).getId()); } }

(2) Creating the POM Descriptor vim pom.xml (3) mvn clean compile exec:java (4) # curl http://localhost:8080 or ie

Hello World

(5) mvn dependency:tree

###Developing a Standard WebApp with Jetty and Maven cd progject dir mkdir -p src/main/java/org/example mkdir -p src/main/webapp/WEB-INF (1) Creating a Servlet

package org.example;

import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;

public class HelloServlet extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); response.setStatus(HttpServletResponse.SC_OK); response.getWriter().println("

Hello Servlet

"); response.getWriter().println("session=" + request.getSession(true).getId()); } }

(2) You need to declare this servlet in the deployment descriptor, so edit the file src/main/webapp/WEB-INF/web.xml and add the following contents: #web.xml

Hello org.example.HelloServlet Hello /hello/*

(3)Creating the POM Descriptor

#The pom.xml

4.0.0 org.example hello-world 0.1-SNAPSHOT war Jetty HelloWorld WebApp

9.0.2.v20130417 org.eclipse.jetty.orbit javax.servlet 3.0.0.v201112011016 provided org.eclipse.jetty jetty-maven-plugin ${jettyVersion}

#(5) mvn jetty:run or mvn jboss-as:deploy You can see the static and dynamic content at http://localhost:8080/hello

There are a great deal of configuration options available for the jetty-maven-plugin to help you build and run your webapp. The full reference is at Configuring the Jetty Maven Plugin. #(6) Building a WAR file to Web Application Archive (WAR) file from the project with the command: mvn package

taglib-json,localCache,ip-seeker

About

api

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0