Tomcat (. jsp)

Source: Internet
Author: User
Tags comparison table jboss ruby on rails apache tomcat

Defined:

The Tomcat server is a free open source Web application server. Tomcat is a core project of the Apache Software Foundation (Apache Software Foundation) Jakarta Project, developed by Apache, Sun, and other companies and individuals. With Sun's involvement and support, the latest servlet and JSP specifications are always reflected in Tomcat, and Tomcat 5 supports the latest servlet 2.4 and JSP 2.0 specifications. Because of the advanced Tomcat technology, stable performance, and free, so deeply loved by Java enthusiasts and has been recognized by some software developers, is currently a popular Web application server.

Basic introduction Tomcat Atlas Tomcat is very popular with programmers because it runs with small system resources, scalability, support for load balancing and messaging services, and other common features of development applications, and it is constantly being improved and perfected. Any interested programmer can change it or add new features to it. Tomcat is a small, lightweight application server that is widely used in small and medium-sized systems and concurrent access users, and is the first choice for developing and debugging JSP programs. For a beginner, it can be thought that when an Apache server is configured on a single machine, it can be used to respond to requests for access to HTML pages. The tomcat part is actually an extension of the Apache server, but it runs independently, so when you run Tomcat, it actually runs separately as a separate process from Apache. The trick here is that when configured correctly, Apache serves HTML pages, while Tomcat actually runs JSP pages and Servlets. In addition, Tomcat, like IIS, Apache and other Web servers, has the capability to handle HTML pages, and it is also a servlet and JSP container, and the standalone servlet container is the default mode for Tomcat. However, Tomcat is less capable of handling static HTML than the Apache server. Version brief version comparison table:
servlet/jsp Spec Apache Tomcat version
———————————————————————
2.5/2.1 6.0.14
2.4/2.0 5.5.25
2.3/1.2 4.1.36
2.2/1.1 3.3.2 Container Overview Tomcat is a free, open-source servlet container that is a core project in the Apache Foundation's Jakarta Project, by Apache,sun and other companies and individuals Developed together. With Sun's involvement and support, the latest servlet and JSP specifications are always reflected in Tomcat. Tomcat was selected by Javaworld Magazine as the most innovative Java product of the 2001, and its position in the industry is visible.

The new servlet container is used in tomcat4.0x: Catalina, which implements the Servlet2.3 and Jsp1.2 specifications completely. Tomcat offers a variety of platform versions for download, which can be downloaded from its official website, either in its source code or in binary. Because of the cross-platform nature of Java, Java-based Tomcat also has a cross-platform nature. Unlike a traditional desktop application, the application in Tomcat is a war (Web Archive) file. The war is a Web application format presented by Sun, similar to a jar and a compressed package for many files.

The files in this package are organized according to a certain directory structure: usually the root directory contains HTML and JSP files or directories containing both files, there will also be a web-inf directory, this directory is very important. Typically there is a Web. xml file and a classes directory under the Web-inf directory, and Web. XML is the configuration file for the application, and the classes directory contains the compiled servlet classes and other classes that the JSP or servlet relies on (such as JavaBean). Usually these dependent classes can also be packaged into a jar under the Web-inf Lib directory, of course, can also be placed in the system's classpath, but that porting and management is inconvenient. Program Deployment

In Tomcat, the deployment of the application is simple, you just put your war into Tomcat's WebApp directory, and Tomcat automatically detects the file and extracts it. When you access the app's JSP in the browser, it's usually very slow for the first time because Tomcat translates the JSP into a servlet file and compiles it. After compiling, the access will be very fast. In addition Tomcat provides an application: Manager, access to the application requires a user name and password, the user name and password stored in an XML file. With this app, you can deploy and revoke apps remotely through the Web, aided by FTP. Of course, local can also.

Tomcat is not just a servlet container, it also has the functionality of a traditional Web server: Working with HTML pages. But compared to Apache, it's handling static HTML is not as good as Apache. You can integrate Tomcat and Apache into one piece, allowing Apache to handle static HTML while Tomcat handles JSPs and servlets. This integration only needs to modify the Apache and Tomcat configuration files.

Tomcat provides realm support. Realm is similar to the Group in Unix. In Unix, a group corresponds to a certain resource of the system, and a group cannot access resources that do not belong to it. Tomcat uses realm to assign different users (like group) to different applications (like system resources). Users without permissions cannot access the app. Tomcat provides three kinds of realm,1:jdbcrealm, a realm that uses the user information in the database and uses JDBC to obtain user information for verification. 2:jndirealm, user information exists in an LDAP-based server, and user information is obtained through JNDI. 3:memoryrealm, the user information exists in an XML file, which is used by the manager application to authenticate users. With realm, you can easily authenticate customers who access an app.

In Tomcat4, you can also use the event Listener feature provided by Servlet2.3 to listen to your app or session. Tomcat also provides other features, such as integration with SSL into a piece, for secure transmission. There is also the Jndi support provided by Tomcat, which is consistent with those of the Java EE Application Server. Here's a look at what's usually said about the difference between the application server (such as WebLogic) and Tomcat. The application server provides more Java features, such as Ejb,jms,jaas, as well as JSP and servlet support. While Tomcat is less powerful, it does not provide support such as EJBS. But if you integrate with JBoss (an open source application server), you can implement the full functionality of the Java EE. Since the application server has Tomcat capabilities, is there any need for Tomcat? In fact, many small and medium-sized applications do not need to use technology such as EJB, JSP and servlet is enough, then if the application server is a bit wasteful. While Tomcat is short, easy to configure, and can meet the needs, this situation will naturally choose Tomcat.

Tomcat-based development is primarily the development of JSPs and Servlets, and the development of JSP and servlet is very simple, you can use a normal text editor or IDE, and then package it into a war. There's another tool to mention here. Ant,ant is also a subproject in Jakarta, which functions like make in UNIX. You need to write a build.xml file, and then run ant to do the work defined in the XML file, which is great for a large application and can be compiled and packaged into a war by simply writing very little in the XML. Ant is included in the release of many application servers. In addition, in the Jsp1.2, you can use the tag library to implement the separation of Java code and HTML files, so that the maintenance of JSP more convenient.

Tomcat can also be integrated with some other software for more functionality. As with the above mentioned JBoss integration to develop EJBS, and Cocoon (another Apache project) to develop an XML-based application, and OPENJMS integrated with the development of JMS applications, in addition to the above mentioned, can be integrated with Tomcat and many other software.

Installation method

First, the preparatory work

Before starting the installation, prepare the J2SDK and Tomcat two software, and if you have installed J2SDK, just Tomcat.
The following software is used:
J2SDK v1.4.2_04-http://java.sun.com/j2se/1.4.2/download.html
TOMCAT V5.0.28-http://apache.linuxforum.net/dist/jakarta/tomcat-5/v5.0.28/bin/jakarta-tomcat-5.0.28.exe

Second, installation J2SDK

Installation is simple, just double-click the downloaded file, select Install in the D:j2sdk1.4.2_04 directory, set the environment variables, the method is as follows:

Right-click on "My Computer" = = "Property = =" Advanced = = "environment variable = =" New
Variable name: java_home
Variable Value: d:j2sdk1.4.2_04

Third, install Tomcat

Run Jakarta-tomcat-5.0.28.exe follow the prompts to install, the service is selected here, is to run as a Windows service.

If you want to change the installation path, you can do this in this step, I choose to install in D:tomcat 5.0

Here you set the port that Tomcat uses and the Web management interface user name and password, make sure that the port is not occupied by other programs

Select the J2SDK installation path, the installer will automatically search, if not displayed correctly, you can manually modify, I changed to D:j2sdk1.4.2_04

The next step is to copy the file, and after successful installation, the program will prompt you to start Tomcat and view the Readme document. Tomcat loads the icon in the system bar after normal startup.

Right-click on the icon to see some setup items

Click Configure or double-click the icon to see the following display, choose Startup type Automatic automatically start, so that each time after the boot automatically run tomcat. You can also click the Start or Stop button on this screen to control the operation of Tomcat.

Iv. Testing

Now that the installation and configuration are complete, open browser input: http://localhost:8080 to see information about Tomcat

Five, remarks

Since I installed Tomcat as a service, the CATALINA_HOME environment variable has not been set, if the reader is not in this way set a system environment variable, set the method with J2SDK.
Variable name: catalina_home
Variable Value: D:tomcat 5.0
Another environment variable can be added
Variable name: CLASSPATH
Variable Value:%java_home%libdt.jar;%java_home%libtool.jar;%java_home%libtools.jar;%catalina_home% Commonlibservlet-api.jar;%catalina_home%commonlibjsp-api.jar

Also, because of the service installation, the following error message appears when executing some programs:
Unable to find a javac compiler; Com.sun.tools.javac.Main are not on the classpath. Perhaps Java_home does not point to the JDK

Error message is not set the JAVA_HOME environment variable, the reader may have encountered this problem, obviously set the environment variable, start in the service will be wrong, but the command line input D:tomcat 5.0binstartup.bat start but can run, start in the service does not read Java_home this environment variable, but in the configuration to define the environment variable, so I added in the Java options:-djava.home=d: J2sdk1.4.2_04, start Tomcat again and it's OK.

Future prospects

Analysts at Forrester Research, an analyst, rated Tomcat like this: "Tomcat is probably the most open source product available after the Apache WEB server and MySQL database." "BZ's latest research has provided strong evidence that Apache Tomcat is the most common application server in the Java community." 64% of Java developers choose to use Tomcat.

The main reasons why Tomcat is popular are the following five points:

1. Tomcat is one of Apache's core projects and is supported by SUN as an important reference for servlet/jsp containers. As a result, SUN's latest servlet/jsp specifications are often quickly reflected in the new version of Tomcat;

2, Tomcat is a small and sophisticated Web application server, configuration, installation, operation, deployment of Web applications are simple, which allows users to quickly get started with;

3. The vitality of open source software is closely related to the situation of the community. In a healthy, active community, the user's questions are usually resolved in a timely manner, and the user's feedback is often handled effectively, which attracts more users to the community, and in turn, the expanding user base will also promote the development of the community. Tomcat has a good community, for developers, no matter what standards to evaluate, are attractive;

4. Writing good documentation is one of the best helpers in the development of the developer. Apache in the open source community, is undoubtedly the leader in writing documents;

5, because of open source and free features, so that users can freely download, install, use Tomcat. This is one of the important reasons that Tomcat can be used extensively.

Tomcat was originally designed and developed as a reference implementation of the Servlet/jsp container, with no undue consideration in terms of performance. After a few years, Apache discovered that servlet/jsp containers are not just part of the EE environment. A large number of Web applications do not require a behemoth like the Java EE, and it is entirely possible to use Tomcat as a separate Web application server.

This is another reason why Tomcat is popular because many developers do not need Java EE components such as EJBS, JMS, distributed transaction processing, and so on. In his book, "Development Without EJB", Rod Johnson points out many of the shortcomings of the Java EE. For example, the Entity EJB in the traditional Java EE 5 (EE) is not very popular. In Java EE 5, obsolete entity EJB components are eliminated, and data persistence is given to the JPA that is affected by these ORM tools in Hibernate. Distributed objects are, in most cases, outdated.

Martin Fowler The first principle of distributed object Design in enterprise Application architecture mode is not to distribute your objects. His advice is to deploy all the components to each node in the cluster. Therefore, for most Web applications, the TOMCAT application server can meet the requirements. With a combination such as spring-struts-hibernate, you can quickly and flexibly develop a web system that meets complex business needs.

In development practice, in addition to Tomcat He Wei also used Resin, the performance of both, Resin 2.x performance than the same period of Tomcat is much better. However, the performance problem continues to improve after Tomcat has implemented a new Catalina engine from its design. Resin, after stepping into the 3.x version, is divided into a free Open Source version and a paid Pro version. Quite a bit of testing has shown that the performance of the Resin 3.x OS is much lower than Tomcat 5/6, and in terms of configuration, Tomcat is a bit more cumbersome than Resin. For Chinese developers, in order to avoid garbled in the system, it is often necessary to make some additional configuration for Tomcat. And Resin in this aspect is very good, in most cases, basically do not have to do any configuration can normally handle Chinese without garbled problem.

In the Resin 3.x Pro, advanced features such as caching and clustering are provided, and if TOMCAT is enhanced in this regard, it is undoubtedly a great thing for developers. Tomcat's future trend, Tomcat is undoubtedly one of the most widely used Web application servers, and there is every reason to believe that such a situation will last for at least a few years. But there are two small, disturbing clouds on the horizon.

The way Ruby on Rails is developed and the high productivity it generates gives Java developers a big jolt. If the Java community is not able to effectively improve Web application development in a timely manner, many Java communities, including Tomcat, will be RoR. Perhaps as Bruce Tate predicted, Java will focus more on solving more complex things in the future, while the common Web application development landscape will gradually give way to highly flexible and fast technologies like ROR.

Source: Baidu Encyclopedia

Tomcat (. jsp)

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.