English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The development environment is the place where you can develop, test, and run Servlets.
Like any other Java program, you need to use the Java compiler javac Compile Servlet, after compiling the Servlet application, deploy it in the configured environment for testing and running.
If you are using the Eclipse environment, you can directly refer to:Eclipse JSP/Servlet Environment Setup.
This development environment setup includes the following steps:
This step involves downloading the Java Software Development Kit (SDK, that is, Software Development Kit) and appropriately setting the PATH environment variable.
You can download the SDK from Oracle's Java website:Java SE Downloads.
Once you have downloaded the SDK, please follow the given instructions to install and configure the settings. Finally, set the PATH and JAVA_HOME environment variables to point to the directory containing java and javac, usually java_install_dir/bin and java_install_dir.
If you are running Windows and installing the SDK in C:\jdk1.5.0_20, you need to add the following line to your C:\autoexec.bat file:
set PATH=C:\jdk1.5.0_20\bin;%PATH% set JAVA_HOME=C:\jdk1.5.0_20
Alternatively, in Windows NT/2000/XP, you can also right-click on "My Computer", select "Properties", and then select "Advanced", "Environment Variables". Then, update the value of PATH and press the "OK" button.
On Unix (Solaris, Linux, etc.), if the SDK is installed in /usr/local/jdk1.5.0_2In 0, and if you are using the C shell, you need to add the following line to your .cshrc file:
setenv PATH /usr/local/jdk1.5.0_20/bin:$PATH setenv JAVA_HOME /usr/local/jdk1.5.0_20
In addition, if you use an integrated development environment (IDE, that is, Integrated Development Environment), such as Borland JBuilder, Eclipse, IntelliJ IDEA, or Sun ONE Studio, compile and run a simple program to confirm that the IDE knows the Java path you have installed.
For more detailed information, please refer to:Java development environment configuration
There are many web application servers on the market that support Servlets. Some web application servers are free to download, and Tomcat is one of them.
Apache Tomcat is an open-source software implementation of Java Servlet and JavaServer Pages technology, which can be used as an independent server for testing Servlets and can be integrated into the Apache Web application server. Here are the steps to install Tomcat on your computer:
From http://tomcat.apache.org/ to download the latest version of Tomcat.
Once you have downloaded Tomcat, unzip it to a convenient location. For example, if you are using Windows, unzip it to C:\apache-tomcat-5.5.29 In the environment variable, if you are using Linux/Unix, then unzip to /usr/local/apache-tomcat-5.5.29 In the environment variable, and create a CATALINA_HOME environment variable pointing to these locations.
On Windows, you can start Tomcat by executing the following command:
%CATALINA_HOME%\bin\startup.bat or C:\apache-tomcat-5.5.29\bin\startup.bat
On Unix (Solaris, Linux, etc.), you can start Tomcat by executing the following command:
$CATALINA_HOME/bin/startup.sh or /usr/local/apache-tomcat-5.5.29/bin/startup.sh
After Tomcat starts, you can enter http://localhost:8080/ Access the default application in Tomcat. If everything goes well, the following result will be displayed:
For more information on configuring and running Tomcat, refer to the documentation installed with the application or visit the Tomcat website:http://tomcat.apache.org.
On Windows, you can stop Tomcat by executing the following command:
C:\apache-tomcat-5.5.29\bin\shutdown
On Unix (Solaris, Linux, etc.), you can stop Tomcat by executing the following command:
/usr/local/apache-tomcat-5.5.29/bin/shutdown.sh
由于 Servlet 不是 Java 平台标准版的组成部分,所以您必须为编译器指定 Servlet 类的路径。
Since Servlet is not part of the Java Platform Standard Edition, you must specify the path to the Servlet class for the compiler.
If you are running Windows, you will need to put the following line in your C:\autoexec.bat file:-tomcat-5.5.29 set CATALINA=C:\apache-api.jar;%CLASSPATH%
Alternatively, in Windows NT/2000/In Windows XP, you can also right-click on 'My Computer', select 'Properties', then 'Advanced', 'Environment Variables'. Then, update the value of CLASSPATH and click the 'OK' button.
On Unix (Solaris, Linux, etc.), if you are using the C shell, you need to put the following line in your .cshrc file:
setenv CATALINA=/usr/local/apache-tomcat-5.5.29 setenv CLASSPATH $CATALINA/common/lib/servlet-api.jar:$CLASSPATH
Note:Assuming your development directory is C:\ServletDevel on Windows or /user/If you are using ServletDevel on UNIX, you will also need to add these directories to your CLASSPATH, in a manner similar to the above method.