Configuring Tomcat and Eclipse Integration in Ubuntu

Source: Internet
Author: User
Tags apache tomcat

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 shown in another article: http://www.linuxidc.com/Linux/2012-10/72635.htm
Installing the JDK under Ubuntu 10.10 Configure Eclipse configuration J2ME

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.

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 to 7.x,home in windows->preferences to the directory in OPT,

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:

    1. <%@ page language="java" contenttype="text/html; Charset=utf-8 "
    2. pageencoding="UTF-8"%>
    • <! DOCTYPE HTML public "-//W3C//DTD HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >
    • <meta http-equiv="Content-type" content= "text/html; Charset=utf-8 ">
    • <title>insert title here</title>
    • <body>
    • <% java.util.Date d =new java.util.Date ();%>
    • </body>

Note: It's best not to use the Apt-get method, which I used earlier, but I was having trouble integrating eclipse.

Right-click the project, Run...>run on server, and select the newly created server. The effect is 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 effect is as follows:

Configuring Tomcat and Eclipse Integration in Ubuntu

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.