File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ web : java -cp target/classes:target/dependency/* HelloWorld
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ set -e; output=" $( curl -s $1 ) " ; echo $output ; test " $output " == " Hello from Java!"
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <project xmlns =" http://maven.apache.org/POM/4.0.0"
3+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
4+ xsi : schemaLocation =" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" >
5+ <modelVersion >4.0.0</modelVersion >
6+ <groupId >com.example</groupId >
7+ <version >1.0-SNAPSHOT</version >
8+ <artifactId >helloworld</artifactId >
9+ <dependencies >
10+ <dependency >
11+ <groupId >org.eclipse.jetty</groupId >
12+ <artifactId >jetty-servlet</artifactId >
13+ <version >7.6.0.v20120127</version >
14+ </dependency >
15+ <dependency >
16+ <groupId >javax.servlet</groupId >
17+ <artifactId >servlet-api</artifactId >
18+ <version >2.5</version >
19+ </dependency >
20+ </dependencies >
21+ <build >
22+ <plugins >
23+ <plugin >
24+ <groupId >org.apache.maven.plugins</groupId >
25+ <artifactId >maven-dependency-plugin</artifactId >
26+ <version >2.4</version >
27+ <executions >
28+ <execution >
29+ <id >copy-dependencies</id >
30+ <phase >package</phase >
31+ <goals ><goal >copy-dependencies</goal ></goals >
32+ </execution >
33+ </executions >
34+ </plugin >
35+ </plugins >
36+ </build >
37+ </project >
Original file line number Diff line number Diff line change 1+ import java .io .IOException ;
2+ import javax .servlet .ServletException ;
3+ import javax .servlet .http .*;
4+ import org .eclipse .jetty .server .Server ;
5+ import org .eclipse .jetty .servlet .*;
6+
7+ public class HelloWorld extends HttpServlet {
8+ @ Override
9+ protected void doGet (HttpServletRequest req , HttpServletResponse resp )
10+ throws ServletException , IOException {
11+ resp .getWriter ().print ("Hello from Java!\n " );
12+ }
13+ public static void main (String [] args ) throws Exception {
14+ Server server = new Server (Integer .valueOf (System .getenv ("PORT" )));
15+ ServletContextHandler context = new ServletContextHandler (ServletContextHandler .SESSIONS );
16+ context .setContextPath ("/" );
17+ server .setHandler (context );
18+ context .addServlet (new ServletHolder (new HelloWorld ()),"/*" );
19+ server .start ();
20+ server .join ();
21+ }
22+ }
You can’t perform that action at this time.
0 commit comments