Servlet environment settings
Development environment is that you can develop, test, run Servlet place.
Just like any other Java program, you need to use the Java compilerjavac compiler Servlet, after compiling Servlet application, deploy it to test and run the configuration environment.
If you are using the Eclipse environment, you can directly see: Eclipse the JSP / build the Servlet environment .
The development environment settings include the following steps:
Setting up the Java Development Kit (Java Development Kit)
This step involves downloading Java Software Development Kit (SDK, namely Software Development Kit), and appropriately set the PATH environment variable.
You can download the SDK from Oracle's Java Web site: Java SE Downloads .
Once you've downloaded the SDK, follow the given instructions to install and configure the settings. Finally, set the PATH and JAVA_HOME environment variables point to java and javac directory contains usually are java_install_dir / bin and java_install_dir.
If you are running Windows, and the SDK is installed in C: \ jdk1.5.0_20, you need in your C: \ autoexec.bat file Add the following line:
set PATH = C: \ jdk1.5.0_20 \ bin;% PATH% set JAVA_HOME = C: \ jdk1.5.0_20
Or, in Windows NT / 2000 / XP, you can also right-click "My Computer" and select "Properties", then select "Advanced", "Environment Variables." Then, update the value of PATH, press the "OK" button.
In Unix (Solaris, Linux, etc.), if the SDK is installed /usr/local/jdk1.5.0_20, and you are using the C shell, you need to put the following lines in your .cshrc file:
setenv PATH /usr/local/jdk1.5.0_20/bin:$PATH setenv JAVA_HOME /usr/local/jdk1.5.0_20
Also, if you use an integrated development environment (IDE, ie 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 know the path of your Java installation.
More detailed information can be found: the Java development environment configuration
Setting Web Server: Tomcat
On the market there are many Web server support Servlet. Some Web server is a free download, Tomcat is one of them.
Apache Tomcat is a Java Servlet and JavaServer Pages technologies open-source software can be used as a standalone server test Servlet, and can be integrated into the Apache Web server. Here is the Tomcat installation steps on your computer:
- From http://tomcat.apache.org/ download the latest version of the Tomcat.
- Once you download the Tomcat, extract it to a convenient location. For example, if you're using Windows, you unzip to C: \ apache-tomcat-5.5.29, if you are using a Linux / Unix, then unzip to /usr/local/apache-tomcat-5.5.29 and create CATALINA_HOME environment variable to point to these locations.
On Windows, you can execute the following command to start Tomcat:
%CATALINA_HOME%\bin\startup.bat 或者 C:\apache-tomcat-5.5.29\bin\startup.bat
In Unix (Solaris, Linux, etc.), you can execute the following command to start Tomcat:
$ CATALINA_HOME / bin / startup.sh Or /usr/local/apache-tomcat-5.5.29/bin/startup.sh
After Tomcat starts, you can enter in the browser address barhttp: // localhost: 8080 / to access the Tomcat default application.If all goes well, it will show the following results:
For further information on configuring and running Tomcat can consult the application documentation for installation, or you can visit the Tomcat Web site: http://tomcat.apache.org .
On Windows, can be stopped by executing the following command Tomcat:
C: \ apache-tomcat-5.5.29 \ bin \ shutdown
In Unix (Solaris, Linux, etc.), the Tomcat can be stopped by executing the following command:
Since part of the Servlet instead of Java Platform Standard Edition, so you must specify the path Servlet class to the compiler.
If you are running Windows, you'll need on your C: \ autoexec.bat file Add the following line:
set CATALINA = C: \ apache-tomcat-5.5.29 set CLASSPATH =% CATALINA% \ common \ lib \ servlet-api.jar;% CLASSPATH%
Or, in Windows NT / 2000 / XP, you can also right-click "My Computer" and select "Properties", then select "Advanced", "Environment Variables." Then, update the value of CLASSPATH, press the "OK" button.
In Unix (Solaris, Linux, etc.), if you are using the C shell, you need to put the following lines in your .cshrc file:
setenv CATALINA = / usr / local / apache-tomcat-5.5.29 setenv CLASSPATH $ CATALINA / common / lib / servlet-api.jar: $ CLASSPATH
Note: If your development directory is C: \ ServletDevel (on Windows) or / user / ServletDevel (on UNIX), you also need to add these directories in the CLASSPATH, add the above manner and add a similar way.