Configure Tomcat and eclipse integration in Ubuntu

Source: Internet
Author: User

Apache Tomcat, as a Web server, has been widely used in Java Servlets and JSP (Java Server Pages) development.

Environment: ubuntu10.10

For configuration of the Java environment, see the following article:
Install JDK in Ubuntu 10.10 and configure eclipse to configure

Http://blog.csdn.net/qp120291570/article/details/6240727

Preparations

Go to atat to download the latest file named tomcapache-tomcat-7.0.30.tar.gz.

Install Tomcat
Download eclipse tomcatplugin

Http://www.eclipsetotale.com/tomcatPlugin.html


Installation Steps

First, extract tomcat to the/OPT directory.
Sudo tar apache-tomcat-7.0.30.tar.gz-C/OPT

Then run start. Up in the bin Folder:



Open your browser and enter the address:

Http: // localhost: 8080/

The following page indicates that the operation is successful.



Note: it is best not to use the apt-Get Method for installation. I used this method before, but encountered problems when integrating eclipse.

Integrate eclipse and tomcat
First, decompress the downloaded plug-in to the Eclipse plug directory. After restarting eclipse, there will be three kittens on the toolbar:

However, the plug-in is not working properly yet. Continue with the Configuration:
In Windows-> preferences, set tomcat, tomcat version to 7.x, and home to the directory in OPT,

You also need to set Tomcat base in Tomcat-> advanced to locate the directory in OPT, and then apply-> OK.

The development environment of Servlet and JSP in eclipse is configured.


Simple Example

1) first create a server

File-> New-> Server:



All the way to the next step.

2) create a dynamic web project

File-> New-> dynamic web project



Just get a name and finish it.

Note: The project's WEB-INF directory does not have a web. xml file.


3) create 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. Shows the running effect:



4) create a Servlet

Select the project, file-> New-> servlet, and fill in the class name.



Click Finish. The servlet class is created in the Java resources-> src directory of the project. Add the code in the doget method:

response.getWriter().write("Hello, world!");


Right-click the servlet, run...> run on server, and select the newly created server. Shows the running effect:




References:

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


Related Article

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.