Jetty installation and configuration

Source: Internet
Author: User

Jetty

Jetty is an open-source servlet container that provides runtime environments for Java-based web content, such as JSP and servlet. Jetty is written in Java and Its APIs are released in the form of a set of jar packages. Developers can instantiate the jetty container into an object and quickly provide network and web connections for some Java applications that run independently (stand-alone.(Jetty is an open-source software that can be used as an HTTP service,Javax. servlet.)

To configure the jetty server, follow these steps:

Create a server

Configure Connector

Configure Handler

Configure Servlet

Start Server

1. Install Maven

Maven is a software project management tool based on the project Object Model (POM). You can use a short description to manage project building, reporting, and documentation.

If you have entered the same ant targets ten times to compile your code, jar or war, and generate javadocs, you will certainly ask yourself, whether there is a method with less repetition but can do the same job. Maven provides such an option to shift your attention from the job layer to the project management layer. Maven projects can now learn how to build and bind code, run tests, generate documents, and host the project webpage.

(1) download and compress the JDK to the/usr/local directory:

[[Email protected] ~] # Chmod 755 jdk-6u5-linux-x64.bin

[[Email protected] ~] #./Jdk-6u5-linux-x64.bin

[[Email protected] ~] # Mv jdk1.6.0 _ 05/usr/local

Establish a JDK soft connection under/usr/local/to facilitate later version upgrade:

[[Email protected] ~] # Ln-S/usr/local/jdk1.6.0 _ 05 // usr/local/JDK

(2) install Apache-Maven and set Environment Variables

[[Email protected] ZY] # tar-zxvf apache-maven-2.2.1-bin.tar.gz

[[Email protected] ZY] # mv apache-maven-2.2.1/usr/local/Maven

[[Email protected] ZY] # Vim/etc/profile

Add the following content:

Java_home =/usr/local/jdk1.6.0 _ 05

Java_bin =/usr/local/jdk1.6.0 _ 05/bin

Path = $ path: $ java_bin:/Usr/local/Maven/bin

Classpath = $ java_home/lib/dt. jar: $ java_home/lib/tools. Jar

Jetty_home =/usr/local/Jetty

Export java_home java_bin path classpath jetty_home

[[Email protected] ZY] # source/etc/profile

[[Email protected] ZY] # MVN -- version

Apache Maven 2.2.1 (r801777; 03:16:01 + 0800)

Java version: 1.6.0 _ 05

Java home:/usr/local/jdk1.6.0 _ 05/JRE

Default locale: en_us, platform encoding: UTF-8

OS name: "Linux" version: "2.6.18-238. EL5" arch: "amd64" Family: "Unix"

2. Install and start Jetty

[[Email protected] ZY] # unzip jetty-distribution-7.3.0.v20110203.zip

[[Email protected] ZY] # mv jetty-distribution-7.3.0.v20110203/usr/local/jetty/

[[Email protected] ZY] # cd/usr/local/jetty/

[[Email protected] jetty] # Java-jar start. JarOr go to the bin directory and run./Jetty. Sh start]

[[Email protected] bin] #./Jetty. Sh start

Starting jetty: started jetty Mon Jul 11 11:54:03 CST 2011

[[Email protected] bin] #11:54:04. 014: info: redirecting stderr/stdout to/usr/local/jetty/logs/20151107_11.stderrout.log

EnterHttp: // 192.168.55.229: 8080/remote.html(add remote.html here to avoidIn fact, http: // 192.168.55.229: 8080 can also be accessed, but the premise is that Tomcat must be disabled. Or change the port number in Jetty. XML to 8081. Now we can directly access http: // 192.168.55.229: 8081)

The jetty directory structure is as follows::
* Contexts hot deployment directory
* ETC jetty configuration file directory
* Examples jetty example
* Extras jetty optional Extension
* LIB contains the jar files required by jetty.
* Licenses is licenses.
* Modules submodule
* Patches patch Patches
* Pom. XML is jetty's maven2 Build File
* Project-website jetty7 website
* Readme.txt
* Start. jar is jetty7 main program
* Version.txt
* The path of the webapps application. Publish references are basically stored here.

3. Simple deployment of an application

[[Email protected] ~] # Cd/usr/local/jetty/webapps/

[[Email protected] webapps] # ls

Test. War

[[Email protected] webapps] # mkdir test1

[[Email protected] webapps] # cd test1

[[Email protected] test1] # vi hello. jsp

<HTML>

<Body>

<H4> simple test </H4>

<% -- Echo Hello World -- %>

<% @ Page Language = "Java" %>

<% = "Hello World" %>

</Body>

</Html>

[[Email protected] test1] # cd/usr/local/jetty/

[[Email protected] jetty] # Java-jar start. Jar

13:34:16. 175: info: deployable added:/usr/local/jetty/webapps/test1

2011-07-1113:34:16. 411: info: started. e. j. w. webappcontext {/test1, file:/usr/local/jetty/webapps/test1/},/usr/local/jetty/webapps/test1

Or run the command./Jetty. Sh start in the bin directory]

[[Email protected] bin] #./Jetty. Sh start

Starting jetty: started jetty Mon Jul 11 13:38:55 CST 2011

[[Email protected] bin] #13:38:56. 122: info: redirecting stderr/stdout to/usr/local/jetty/logs/20151107_11.stderrout.log

Enter:Http: // 192.168.55.229: 8080/test1/Hello. jsp

Jetty installation and configuration

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.