Apache Tomcat has been extensively developed as a Web server for Java servlets and JSP (Java server Pages).
Environment: Ubuntu10.10
The configuration of the Java environment is described in another article:
Installing the JDK under Ubuntu 10.10 Configure Eclipse configuration J2ME
http://blog.csdn.net/qp120291570/article/details/6240727
preparatory work
Go to Tomcat official website download good Tomcat7.0, last download good filename similar to apache-tomcat-7.0.30.tar.gz
Installing Tomcat
Download the Eclipse plugin Tomcatplugin
Http://www.eclipsetotale.com/tomcatPlugin.html
installation Steps first unzip the tomcat to the/OPT directory
sudo tar zxvf apache-tomcat-7.0.30.tar.gz-c/opt
Then run the start.up directly inside the Bin folder:
Open the browser and enter the address:
http://localhost:8080/
Seeing the following page indicates that the operation was successful.
Note: It's best not to use the Apt-get method, which I used earlier, but I was having trouble integrating eclipse.
Integrate Eclipse and Tomcat
First, the downloaded plugin is unpacked into the eclipse's plug directory, and three kittens appear on the toolbar after you restart eclipse:
However, plug-ins are not working properly and continue to configure:
Set Tomcat,tomcat version in Windows->preferences to 7.x,home in the OPT directory, as shown in figure:
You also need to set the Tomcat base in tomcat->advanced to locate the directory in OPT, and then Apply->ok.
The development environment for Servlets and JSPs in Eclipse is even configured.
a simple example
1) First create a server
File->new->server:
The next step will be all right.
2) Create a Dynamic Web project
File->new->dynamic Web Project
Just take a name, and finish is fine.
Note: There is no web. xml file under the project's Web-inf directory.
3) Create the index.jsp in the WebContent directory
file->new->jsp File
Code:
<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "
pageencoding=" UTF-8 "%>
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >
Right-click the project, Run...>run on server, and select the newly created server. The results of the operation are as follows:
4) Create servlet
Select the item just now, File->new->servlet, fill in the class name.
The point Finish,servlet class is created in the Java RESOURCES->SRC directory in the project, adding code in the Doget method:
Response.getwriter (). Write ("Hello, world!");
Right-click on the servlet, Run...>run on server, select the newly created server. The results of the operation are as follows:
Reference article: https://help.ubuntu.com/11.04/serverguide/tomcat.html
Http://www.blogjava.net/waterjava/archive/2007/07/20/131399.html
Http://www.cnblogs.com/younggun/archive/2011/05/18/2050490.html