Tomcat configuration and how to start it in Eclipse

Tomcat configuration and how to start it in Eclipse

How to install and configure Tomcat8

Apache Tomcat is the most common and popular Java-based web container. In this article, I will show you how to install tomcat8 and tweak the configuration files.

The main advantages of Tomcat are its small footprint, simple configuration, and long history of community involvement. Typically, a developer can have a functional Tomcat installation up and running in 5 to 10 minutes (including the tomcat download time). Tomcat requires very little out-of-the-box configuration to run well on a development machine, but it can also be tuned significantly to run well in a high-load, high-availability production environment. You can create large Tomcat clusters to reliably handle large amounts of traffic. Due to its simplicity and lightweight, Tomcat is often used in commercial production environments.

The following table shows the Tomcat versions and their specifications:

tomcat download

Go to http://tomcat.apache.org/download-80.cgi and scroll down to "Binary Distributions" -> "Core". For Windows, you can choose between the service installer or the 32-bit or 64-bit ZIP version. If you prefer to run Tomcat as a Windows service, rather than the installer, choose the ZIP download if you prefer to run the server manually or integrate with an IDE.

If you're running on Linux or OSX, download the non-Windows zip, which is what it's called.

Enable Tomcat Manager

Tomcat Manager allows you to easily manage applications and monitor server status.

To enable it, open conf/tomcat-users.xml in your favorite text editor and place the following line between <tomcat users> and <tomcat users> tags:

<user username="admin" password="admin" roles="manager-gui,admin-gui" />

Of course you can set your username and password at will.

You can access the manager application at http://localhost:8080/ after starting the manager server.

Change the Servlet compiler to use Java8

By default, Tomcat 8.0 compiles Java Server Pages ( JSP ) using Java SE 6 language support, even if it runs on Java SE 8. You can change this in conf/web.xml file. Search the file for the text org.apache.jasper.servlet.JspServlet . Below the tag containing this text are two <init param> tags. Change these two values ​​from 1.6 to 1.8

<init-param>
 <param-name>compilerSourceVM</param-name>
 <param-value>1.8</param-value>
</init-param>
<init-param>
 <param-name>compilerTargetVM</param-name>
 <param-value>1.8</param-value>
</init-param>

How to Start and Stop the Tomcat Server

After completing all the configurations, you can start Tomcat to use it. If you use Windows as the host operating system, you may want to check this article before starting the Tomcat server: jdk environment variable configuration

Starting Tomcat is as simple as going to the /bin folder and executing startup.bat for Windows or running startup.sh for Linux or OSX.

To stop Tomcat execute shutdown.bat on Windows OS or shutdown.sh on Linux or OSX systems.

Running Tomcat from Eclipse

Here's how to set up and run Apache Tomcat 8 from Eclipse IDE

So why run Tomcat from eclipse? There are several reasons. First, you can debug your application directly without running the Tomcat standalone server in debug mode. Second, you can run JUnit tests on your application before deploying it. Third, you can deploy your application directly from Eclipse.

Setting up Tomcat in Eclipse

Note: Before following the steps below, make sure you are running a newer version of Eclipse IDE. Eclipse versions earlier than Eclipse Luna 4.4 do not support Tomcat 8 by default. In this tutorial, I used Eclipse Mars 2 for Java EE Developers.

1. In Eclipse for Java EE, go to Window->Preferences in Windows OS (or Eclipse->Preferences on Mac)

2. Go to Server and click Runtime Environment

3. Click the “Add…” button

4. Select tomcat8 in the Apache tree and check the box "Create a new local server"

5. On the next screen click “Browse…” and select your Tomcat installation directory. In the JRE drop-down list, select the local java8se installation and click the "Finish" button to confirm

Tip: Eclipse will use the built-in browser to open web applications. You can change this setting to a more convenient browser like Google Chrome or Firefox. To do this, go to Window->Web Browser and select Default system web browser

Running the application from Eclipse on a local server

Now that you have configured Tomcat to run in Eclipse, you can easily run your application on this server. To do this, right-click on the project in the Project Explorer and go to Run As -> Run on Server

On the next screen select Apache Tomcat 8. This will deploy your application and open it for you in a browser window.

This is the end of this article about Tomcat configuration and how to start it in Eclipse. For more information about Tomcat configuration in Eclipse, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Regarding the configuration method of JDK+Tomcat+eclipse+MyEclipse, it is enough to read this article
  • Tomcat9 download, installation and configuration + detailed tutorial on integrating into eclipse
  • How to configure tomcat server for eclipse and IDEA
  • Import Maven Web project into Eclipse and configure it to run in Tomcat
  • Solve the error Cannot create a server using the selected type when configuring Tomcat in Eclipse
  • Summary of detailed steps for eclipse configuration tomcat10

<<:  mysql implements the operation of setting multiple primary keys

>>:  W3C Tutorial (1): Understanding W3C

Recommend

HTML 5 Reset Stylesheet

This CSS reset is modified based on Eric Meyers...

IE8 Developer Tools Menu Explanation

<br />This article has briefly explained the...

Detailed explanation of Vue save automatic formatting line break

I searched for many ways to change it online but ...

Example code for implementing a pure CSS pop-up menu using transform

Preface When making a top menu, you will be requi...

What are the differences between var let const in JavaScript

Table of contents 1. Repeated declaration 1.1 var...

Learn to deploy microservices with docker in ten minutes

Since its release in 2013, Docker has been widely...

Problems with creating placeholders for HTML selection boxes

I'm using a placeholder in a text input and i...

How to uninstall MySQL 8.0 version under Linux

1. Shut down MySQL [root@localhost /]# service my...

Design Theory: A Method to Understand People's Hearts

<br />Once, Foyin and Mr. Dongpo were chatti...

HTML left and right layout example code

CSS: Copy code The code is as follows: html,body{ ...

What qualities should a good advertisement have?

Some people say that doing advertising is like bei...

A brief discussion on the implementation principle of Vue slot

Table of contents 1. Sample code 2. See the essen...

Implementation of docker view container log command

Why should we read the log? For example, if the c...

CSS 3.0 text hover jump special effects code

Here is a text hovering and jumping effect implem...

How to implement call, apply and bind in native js

1. Implement call step: Set the function as a pro...