Java Servlet and JSP tutorial (2)
2 Installation
2.1 install Servlet and JSP development tools
To learn about Servlet and JSP development, you must first prepare a development environment that complies with the Java Servlet 2.1/2.2 and JavaServer Pages1.0/1.1 specifications. Sun provides free JavaServer Web Development Kit (JSWDK), which can be downloaded from http://java.sun.com/products/servlet.
After JSWDK is installed, you need to tell javac where to find Servlet and JSP classes during File compilation. The JSWDK installation guide describes this in detail, but the main ?? Add servlet. jar and jsp. jar to CLASSPATH. CLASSPATH is an environment variable that indicates how Java looks for class files. If CLASSPATH is not set, Java searches for classes in the current directory and standard system Library. If CLASSPATH is set by yourself, do not forget to include the current directory (that is, include ". ").
In addition, to avoid name conflicts with servlets installed on the same Web server by other developers, it is best to put your Servlet into the package. Adding the top-level directory in the package hierarchy to CLASSPATH makes it much easier. For more information, see the following description.
2.2 install a Web server supporting Servlet
In addition to development tools, you also need to install a Web server that supports Java Servlet, or install the Servlet software package on an existing Web server. If you are using the latest Web server or application server, it is likely that it has all the necessary software. Please refer to the Web server documentation or visit the server software license that supports servletat http://java.sun.com/products/servlet/industry.html.
Although Servlet is often run on commercial servers, it is sufficient to develop and test it with a free system that can run on a desktop. Below are several of the most popular products currently.
Apache Tomcat.
Tomcat is the official reference implementation for Servlet 2.2 and JSP 1.1 specifications. Tomcat can be used as a small Servlet, JSP testing server, or integrated into the Apache Web server. Until the early 2000 s, Tomcat was the only server supporting Servlet 2.2 and JSP 1.1 specifications, but many other servers have announced support in this regard.
Tomcat is free of charge like Apache. However, it is a bit difficult to install and configure a fast and stable Apache server. Tomcat has the same disadvantages. Compared with other commercial Servlet engines, it is much more work to configure Tomcat? ? Http://jakarta.apache.org /.
Assumerver Web Development Kit (JSWDK ).
JSWDK is the official reference implementation for Servlet 2.1 and JSP 1.0. Before deploying Servlet and JSP applications to the servers that officially run them, JSWDK can be separately used as a small Servlet and JSP test server. JSWDK is free and stable, but its installation and configuration are also complicated? ? Http://java.sun.com/products/servlet/download.html ?? BR>;
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.