Use of the Java servlet

Source: Internet
Author: User
The servlet Java servlet is a Java code that runs on a Web server that accepts user requests, processes them, and provides feedback to users. Its function is similar to CGI program, can realize many interactive effect in webpage, but more efficient than CGI program.


1. Software Download





Development Software has two: jdk1.x and jswdk1.x.x.





to http://java.sun.com, the downloaded JDK may also be j2sdk1.4.1_07 files installed on your computer.





JSWDK1.0.1 can be downloaded from the http://java.sun.com/products/jsp/download.html. Downloaded Jswdk1_0_1-win.zip with WinZip software to a directory, such as: D:\, this directory will automatically create a subdirectory: jswdk-1.0.1. At this time JSWDK 1.0.1 has been installed in the d:\jswdk-1.0.1 directory.





2. Start JSWDK 1.0.1





SET environment variable:





set CLASSPATH=C:JDK1. X\bin;.





set PATH=C:JDK1. X\bin (may not be the same, it depends on how you install the program to that directory)





then runs Startserver.bat in the DOS window using the CD command into the JSWDK 1.0.1 installation directory (such as d:\jswdk-1.0.1).





displays a string of strings after running, and finally displays endpoint created:localhost/127.0.0.1:8080. Indicates that the normal boot is complete. However, it does not support queries for text segments and Chinese values in the database.





Open a browser, enter: http://your machine IP address: 8080, when the browser displays the page of the vacant province, the page can view the servlet example.


Enter the command in the previous DOS window:





set PATH=C:JDK1. X\bin;


set CLASSPATH=C:JDK1. X\bin;d:\jswdk-1.0.1\lib\servlet.jar





to set the environment variable.





javac Xx.java compiler Java program





copy *.class D:\jswdk-1.0.1\examples\WEB-INF\servlets





copies the compiled program to the Java servlet Runtime directory.





* If you use the old version of JDK1.2, you will need to modify a file in order to run the Java servlet Program:





D:\jswdk-1.0.1\examples\WEB-INF\servlets.properties





Open the file with a text editor and add a few lines to it at the end:





xx.code=xx





Xx.initparams=foo





Enter the IP address of the http://machine in the browser: 8080/EXAMPLES/SERVLET/XX, you will experience the effect of the servlet.











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.