About Linux Tomcat

Source: Internet
Author: User
Tags event listener jboss

Today, with more and more web-based applications, traditional HTML is not enough to meet today's needs. We need an interactive web, so we have a variety of web languages. such as asp,jsp,php and so on. Of course, these languages are closely related to traditional languages, such as PHP based on the C and C + + languages, and JSP based on the Java language. The Tomcat described in this article is a running platform for JSPs and Servlets.

One: What are JSPs and Servlets

JSP (JavaServer Page) is a script that embeds Java code in plain HTML, at this point, it is the same as other scripting languages (such as PHP), but unlike other languages: other scripting languages are interpreted directly by the server, The JSP is then converted to a servlet by a JSP container (such as Tomcat) and then called Javac to compile the servlet into a class file. Finally, the server interprets the class file. So what is a servlet? The servlet is actually a special Java class, and the servlet class is generally inherited from the HttpServlet class, where at least the Doget or Dopost function is implemented, in which the requests from the client are processed and the result is returned. Servlets and JSPs are an important part of Sun's Java EE architecture. Because of the Java-based language, it makes it easy to invoke powerful Java APIs such as JDBC.

II: Tomcat Overview

Tomcat is a free open source Serlvet container, a core project of the Apache Foundation's 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. Tomcat was selected by Javaworld Magazine as the most innovative Java product of the 2001, and its position in the industry is visible.

The latest version of Tomcat is 4.0x. The 4.0x and 3.x architectures are different, but redesigned. 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 the http://jakarta.apache.org version or binary plate. 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.

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, its ability to handle static HTML is inferior to that of Apache. We 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.

In addition, Tomcat provides realm support. Realm is similar to the Group within 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, we can easily authenticate customers who visit 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. Speaking of which, we're going to talk about how the common application server (such as WebLogic) differs from 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 of our small and medium-sized applications do not require the use of technology such as EJB, JSP and servlet is enough, when using the application server is a bit wasteful. While Tomcat is short, easy to configure and can meet our needs, we will naturally choose Tomcat in this case.

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. We're going to mention another tool here. Ant,ant is also a sub-project 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 very good for a large application, and we can compile and package it as a war simply by writing very little in the XML. In fact, Ant is included in the release of many application servers. In addition, in Jsp1.2, we can use the tag library to realize the separation of Java code and HTML file, so that the maintenance of JSP is 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 XML-based applications, and OPENJMS

Integrated with the development of JMS applications, there are many more software that can be integrated with Tomcat, in addition to the few we have mentioned.

Three: Outlook

Tomcat is really a great tool, not only because it's free, powerful, but also because of its openness. Today, open source software is receiving more and more attention, Linux is a typical success. People are no longer limited to using software only, and are already concerned with the implementation of the software. We have reason to believe that Tomcat will go further.

The source of this article: collection, collation from the Internet

About Linux Tomcat

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.