Jetty Use Tutorial (i) Start using jetty

Source: Internet
Author: User
Tags documentation rfc
1.1 What is jettyJetty is an open source project that provides HHTP servers, HTTP clients, and Javax.servlet containers. This introductory tutorial is divided into five parts: the first part focuses on how to use jetty, which provides information such as what is jetty, where to download it, and how to find it in a repository like maven. This section also provides a quick start to starting jetty and configuring jetty. The second section introduces the configuration of jetty in more detail, describes how to deploy a Web application using jetty, how to configure containers and connections, and how to implement SSL and other security measures. The jetty administrator should focus on the third part. From starting jetty containers to session management, logging, HTTP/2 support, and jetty optimization, this section will help jetty administrators get more knowledge about jetty services, which also includes the most common feature configurations for containers such as Jndi and JMX. For advanced users using jetty, Part IV focuses on jetty development, and this chapter focuses on how to embed jetty in an existing application. This section contains a few simple examples and guidelines for manipulating the jetty framework. This section also includes how to use the jetty Maven plug-in and jetty debugging. The final section is a reference section, also contains jetty schema information, an introduction to Jetty's XML syntax, and an analysis of common problems, which also describes how to participate in the jetty community, how to contribute code, and how to ask for help. 1.2 How to select the jetty versionJetty9 is the most recent version of Jetty and has improved significantly from previous versions, with one improvement being that jetty all features are already in Jetty9 documentation. So for many users who use the old jetty version, we recommend using Jetty9, and we also say that we will be actively maintaining this version over the next few years. form 1.1Jetty version Year Home
version JVM Protocol Servlet JSP State

9.3

2015

Eclipse

1.8

http/1.1 (RFC 7230), HTTP/2 (RFC 7540),

WebSocket (RFC 6455, JSR 356), FastCGI

3.1

2.3

Stable version

9.2

2014

Eclipse

1.7

http/1.1 RFC2616, Javax.websocket, SPDY v3

3.1

2.3

Stable version

8

2009-

Eclipse/codehaus

1.6

http/1.1 RFC2616, WebSocket RFC 6455, SPDY v3

3.0

2.2

Precious version

7

2008-

Eclipse/codehaus

1.5

http/1.1 RFC2616, WebSocket RFC 6455, SPDY v3

2.5

2.1

Precious version

6

2006-2010

Codehaus

1.4-1.5

http/1.1 RFC2616

2.5

2.0

has been voided

5

2003-2009

Sourceforge

1.2-1.5

http/1.1 RFC2616

2.4

2.0

has been voided

4

2001-2006

Sourceforge

1.2, J2ME

http/1.1 RFC2616

2.3

1.2

Ancient times

3

1999-2002

Sourceforge

1.2

http/1.1 RFC2068

2.2

1.1

Stone age

2

1998-2000

Mortbay

1.1

http/1.0 RFC1945

2.1

1.0

Legend level

1

1995-1998

Mortbay

1.0

http/1.0 RFC1945

-

-

Myth level



1.3 Jetty and Java EE Web specification The Java EE specification implemented by Jetty is primarily a servlet specification, and the latest Java EE platform introduces a new Web specification, suggesting that developers need only part of most of the technology. However, Jetty does not implement all the techniques in the Web specification, jetty is designed as a container that allows you to freely extend the functionality you want with plug-ins. The 1.3.1 Java EE 7 Web specification , in the Java EE7 specification, updates some important features and adds new: Table 1.2 JavaEE7 Web profile

JSR name whether the jetty-9.1.x contains Support Plug-ins

JSR 340

Servlet Specification API 3.1

Yes

JSR 344

Java Server Faces 2.2 (JSF)

No

Yes, Mojarra or myfaces

JSR 245/JSR 341

Java Server Pages 2.3/java Expression Language 3.0 (jsp/el)

Yes

Yes

JSR 52

Java Standard Tag Library 1.2 (JSTL)

Yes

Yes

JSR 45

Debugging Support for the other Languages 1.0

Yes (via JSP)

Yes (via JSP)

JSR 346

Contexts and Dependency injection for the

Java EE Platform 1.1 (Web Beans)

No

Yes, Weld.

JSR 330

Dependency Injection for Java 1.0

No

Yes as part of a CDI implementation, Weld

JSR 316

Managed Beans 1.0

No

Yes, as part of another technology

JSR 345

Enterprise JavaBeans 3.2 Lite

No

JSR 338

Java persistance 2.1 (JPA)

No

Yes, eg Hibernate

JSR 250

Common annotations for the Java Platform 1.2

Yes

Partially (for Non-core Servlet Spec annotations)

JSR 907

Java Transaction API 1.2 (JTA)

Yes

Yes

JSR 349

Bean Validation 1.1

No

Yes as part of another technology eg JSF, or

A stand-alone implementation such as Hiberate Validator

JSR 339

Java API for RESTful Web Services 2.0 (JAX-RS)

No

JSR 356

Java API for Websocket 1.0

Yes

No

JSR 353

Java API for JSON Processing 1.0 (JSON-P)

No

Yes, eg json-p reference implementation

JSR 318

Interceptors 1.2

No

Yes as part of a CDI implementation


1.3.2 Jetty EE 6 Web profile

The following describes JavaEE6 Web profile and its relationship to jetty

Table 1.3. Java EE 6 Web profile

JSR Name Included with jetty-9.0.x Pluggable

JSR 315

Servlet Specification API 3.0

Yes

JSR 314

JavaServer Faces 2.0 (JSF)

No

Yes, for example, Mojarra or myfaces

JSR 245

JavaServer Pages 2.2/java Expression

Language 2.2 (Jsp/el)

Yes

Yes

JSR 52

Java Standard Tag Library 1.2 (JSTL)

Yes

Yes

JSR 45

Debugging Support for the other Languages 1.0

Yes (via JSP)

Yes (via JSP)

JSR 299

Contexts and Dependency injection for

The Java EE Platform 1.0 (Web Beans)

No

Yes, Weld or Openwebbeans

JSR 330

Dependency Injection for Java 1.0

No

Yes as part of a CDI implementation, Weld

JSR 316

Managed Beans 1.0

No

Yes, as part of another technology.

JSR 318

Enterprise JavaBeans 3.1

No

Yes, OPENEJB.

JSR 317

Java persistance 2.0 (JPA)

No

Yes, Hibernate.

JSR 250

Common annotations for the Java Platform

Yes

Partially (for Non-core Servlet Spec annotations)

JSR 907

Java Transaction API (JTA)

Yes

Implementations are pluggable, such as Atomikos, JOTM,

Jencks (Geronimo Transaction Manager)

JSR 303

Bean Validation 1.0

No

Yes as part of another technology (JSF), or a stand-alone

Implementation such as Hiberate Validator

1.4 getting jetty in maven   1.4.1 Maven coordinates Jetty has been in the MAVEN center since the beginning, so the coordinates of MAVEN have changed in recent years, and when Jetty is based on SourceForge management, MAVEN's groupid is org.mortbay.jetty when jetty The GroupID also changed after 7来 to eclipse. The POM coordinates of the jetty are as follows

<dependency>
  <groupId>org.eclipse.jetty</groupId>
  <artifactid>jetty-project </artifactId>
  <version>${project.version}</version>
</dependency>
1.4.2 Update log in the MAVEN center




Jetty different versions of the update log are recorded in a file called VERSIONS.txt, which can also be found in the MAVEN center, coordinates as follows

<dependency>
  <groupId>org.eclipse.jetty</groupId>
  <artifactid>jetty-project </artifactId>
  <version>${project.version}</version>
  <classifier>version</ classifier>
  <type>txt</type>
</dependency>
second, the use of jetty



There are a number of ways you can use a jetty implant in a different system, or as a stand-alone server, which describes the latter as a separate server for deploying Web applications. 2.1 Download Jetty   2.1.1 Download Jetty Project Jetty's Download page is: https://www.eclipse.org/jetty/download.html If the JDK environment supports using the latest version as much as possible, the downloaded decompression will be placed where it is used, and later chapters will use Jetty_home or $ ( Jetty.home) to represent the storage path of the jetty.   Brief introduction of 2.1.2 Jetty Project Jetty all top-level catalogs:

Table 2.1. Contents

Location Description

License-eplv10-aslv20.html

Jetty's license file

README.txt

Useful Start Information

VERSION.txt

Version information

bin/

A shell script that runs under a UNIX system

demo-base/

A jetty server base directory that can run with a sample Web application

etc/

Jetty configuration file

lib/

Jetty required to run the jar file

logs/

Log

modules/

Each module

Notice.html

Licensing information, etc.

resources/

Include new to classpath configuration folder, such as Log4j.properties

Start.ini

Store startup information

Start.jar

Running the jetty jar

webapps/

A jetty Web application directory for running under the default configuration


2.2 Run Jetty execute the following code, jetty will run on the default 8080 port

CD $JETTY _home
Java-jar Start.jar

The following information will be exported if successful execution




2015-06-04 10:50:44.806:info::main:logging initialized @334ms
2015-06-04 10:50:44.858:warn:oejs. HomeBaseWarning:main:This instance of Jetty is not running from a separate {jetty.base} directory, which is not recommende D. Documentation at http://www.eclipse.org/jetty/documentation/current/startup.html
2015-06-04 10:50:44.995 : Info:oejs. server:main:jetty-9.3.0.v20150601
2015-06-04 10:50:45.012:INFO:OEJDP. ScanningAppProvider:main:Deployment Monitor [file:///opt/jetty-distribution-9.3.0.v20150601/webapps/] at interval 1
2015-06-04 10:50:45.030:info:oejs. ServerConnector:main:Started serverconnector@19dfb72a{http/1.1,[http/1.1]}{0.0.0.0:8080}
2015-06-04 10:50:45.030:info:oejs. Server:main:Started @558ms

You can access http://localhost:8080 through the browser. However, there is no < in the Jettyhome/webapps directory

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.