Jetty installation and configuration

Jetty

Jetty is an open source servlet container, which provides a runtime environment for Java-based web content, such as JSP and servlet. Jetty is written in Java language, and its API is released in the form of a set of JAR packages. Developers can instantiate the Jetty container into an object, which can quickly provide network and web connections for stand-alone Java applications. (Jetty is an open source software that can be used as a container for HTTP services, javax.servlet.)

Steps to configure jetty server:

Create server

Configure connector

Configure handler< /p>

Configure servlet

Start server

1. Install maven

Maven is a software based on the Project Object Model (POM), which can manage project construction, reports and documents through a short description of information Project management tool.

  If you have entered the same Ant targets ten times to compile you Code, jar or war, generate javadocs, you must ask yourself if there is a way to do the same job with less repetition. Maven provides such an option to shift your attention from the job level to the project management level. The Maven project already knows how to build and bundle code, run tests, generate documentation and host the project web page.

(1) Download and press jdk and place it under the /usr/local directory:

[root@master ~]#chmod 755 jdk-6u5-linux-x64.bin

[root@master ~]# ./jdk-6u5-linux-x64.bin

[root@master ~]#mv jdk1.6.0_05 /usr/ local

< span style="color:rgb(255,153,102); background-color:rgb(51,255,51)">Establish a jdk soft connection under /usr/local/ to facilitate future version upgrades:

[root@master ~]# ln -s /usr/local/jdk1.6.0_05/ /usr/local/jdk

(2) Install apache-maven and set environment variables

[root@master zy]# tar -zxvf apache-maven-2.2.1-bin.tar.gz

[root@master zy]# mv apache-maven-2.2.1 /usr/local/maven

[root@master zy]#vim /etc/profile

Add the following:

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

[root@master zy]# source /etc/profile

[root@master zy]# mvn –version

Apache Maven 2.2.1 (r801777; 200 9-08-07 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

[root@master zy]# unzip jetty-distribution-7.3.0.v20110203.zip

[root@master zy]# mv jetty-distribution-7.3.0.v20110203 /usr/local/jetty/

[root@master zy]# cd /usr/local/jetty/

< p style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:26px"> [root@master jetty]# java -jar start.jar [Or go to the bin directory and execute ./jetty.sh start]

[root@master bin]# ./jetty.sh start

Starting Jetty: STARTED Jetty Mon Jul 11 ​​11:54:03 CST 2011

[root@master bin]# 2011-07-11 11:54 :04.014:INFO::Redirecting stderr/stdout to /usr/local/jetty/logs/2011_07_11.stderrout.log

Type in the browserhttp://192.168.55.229:8080/remote.html(The reason for adding remote.html here is to avoid tomcatconflict, in fact, http://192.168.55.229:8080 can also be accessed, but the premise is that tomcat must be banned. Or change the port to 8081 in jetty.xml, then we can directly visit 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 Patches
* pom.xml is jetty’s maven2 build file
* project-website jetty7 website
* README.txt readme.txt
* start.jar is jetty7主程序
* VERSION.txt
* webapps应用路径,发布的引用基本都放这里

3. Simple deployment of an application

[root@master ~]# cd /usr/local/jetty/webapps/

[root@master webapps]# ls

test.war

[ root@master webapps]# mkdir test1

[root@ master webapps]# cd test1

[root@master test1 ]# vi hello.jsp

< p style="color:rgb(51,51,51); font-f amily:Arial; font-size:14px; line-height:26px">

simple test

< %--echo hello world--%>

< %@page language="java"%>

< %="Hello World"%>

[root@master test1]# cd /usr/local/jetty/

[root@localhost jetty]#java -jar start.jar

2011-07-11 13:34:16.175:INFO::Deployable added: /usr/local/jetty/webapps/test1

2011-07-1113:34:16.411:INFO::started.ejwWebAppContext {/test1,file:/usr/local/jetty/webapps/test1/},/usr/local/jetty/webapps/test1

[Or go to the bin directory and execute the command. /jetty.sh start]

[root@master bin]# ./jetty.sh start

Starting Jetty: STARTED Jetty Mon Jul 11 ​​13:38:55 CST 2011

[root@master bin]# 2011-07-11 13:38:56.122:INFO: :Redirecting stderr/stdout to /usr/local/jetty/logs/2011_07_11.stderrout.log

Type in the browser:http://192.168.55.229:8080/test1/hello.jsp

Original address: http://www.voidcn.com/article/p-vdedorxp-bky.html

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 4569 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.