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

How to hide the version number and web page cache time in Nginx

Nginx optimization---hiding version number and we...

Detailed explanation of the getBoundingClientRect() method in js

1. getBoundingClientRect() Analysis The getBoundi...

Tips on MySQL query cache

Table of contents Preface Introduction to QueryCa...

Detailed explanation of asynchronous iterators in nodejs

Table of contents Preface What are asynchronous i...

How to use Nginx to proxy multiple application sites in Docker

Preface What is the role of an agent? - Multiple ...

VMware configuration VMnet8 network method steps

Table of contents 1. Introduction 2. Configuratio...

JavaScript implementation of magnifying glass details

Table of contents 1. Rendering 2. Implementation ...

Vue realizes click flip effect

Use vue to simply implement a click flip effect f...

WeChat Mini Program implements the likes service

This article shares the specific code for the WeC...

How CSS affects the white screen time during initial loading

Rendering pipeline with external css files In the...

How to decompress multiple files using the unzip command in Linux

Solution to the problem that there is no unzip co...

MyBatis dynamic SQL comprehensive explanation

Table of contents Preface Dynamic SQL 1. Take a l...

How to quickly build ELK based on Docker

[Abstract] This article quickly builds a complete...

Detailed tutorial on installing MySQL 8.0 from source code on CentOS 7.4

Table of contents 1. Environment 2. Preparation 3...