Use of assumervlet and Cookie _ MySQL

Source: Internet
Author: User
This article describes the software and environment configurations required for assumervlet programming. As long as you have a PC with Windows9598 installed, you can follow the steps in this article to develop the Servlet program. This article also provides methods and routines for writing and reading cookies to users' hard disks through assumervlet. It can be used to implement common personalized web pages, online shopping baskets, and Cookieservlet on the Internet.

This article describes the software and environment configurations required for Java Servlet programming. As long as you have a PC with Windows 95/98 installed, you can follow the steps in this article to develop the Servlet program. This article also provides methods and routines for writing and reading cookies to users' hard disks through Java Servlet. It can be used to implement common personalized web pages, online shopping baskets, and password verification on the Internet.


Java Servlet is the Java code running on the Web server. it can accept user requests, process them accordingly, and provide feedback to users. Similar to CGI programs, it can achieve a lot of interactive effects on web pages, but it is more efficient than CGI programs. Cookies are a small piece of information written by the Web server into a specific directory of your computer when you access the Web server. Java Servlet provides a Cookie class that allows you to operate on Cookies. You can write cookies to your computer at specific times and use them again when necessary.

1. software download

PC, install Windows 95/98, with an IP address (if not available, you can configure it as needed ). There are two types of software: JDK1.3 and JSWDK1.0.1.


Go to the http://java.sun.com and click the "Products & APIs" link to download "JavaTM 2 SDK, Standard Edition, v 1.3 ". Install the downloaded file on your computer.

JSWDK1.0.1 only has 763,414 bytes, which can be downloaded from http://java.sun.com/products/jsp/download.html. Download the jswdk1_0_1-win.zip to a directory, such as: d: app, the directory will automatically create a sub-directory: jswdk-1.0.1. Then JSWDK 1.0.1 has been installed in the d: appjswdk-1.0.1 directory.

2. start JSWDK 1.0.1

Open a DOS window. for example, click the DOS icon in the upper left corner of the window, select the attribute menu, and click "memory" in the window that appears ", change "auto" to 2816 in the drop-down menu after "initial environment", click "exit" to exit the window, and then enter the DOS window again. This setting only needs to be done once.

Run the following doscommand in the DOS window to set environment variables:

Set CLASSPATH = c: jdk1.3bin ;.

Set path = c: jdk1.3bin; c: windows; c: windowscommand

If your JDK 1.3 and Windows operating systems are installed in other directories, modify the directory name in the doscommand.

Then run the CD command in the DOS window to enter the JSWDK 1.0.1 installation directory (such as d: appjswdk-1.0.1) and run startserver. bat.

Note:

For JDK1.3, that is, the environment described in this article, you need to modify startserver. bat

Start java com. sun. web. shell. Startup % 1% 2% 3% 4% 5% 6% 7% 9

Rem java com. sun. web. shell. Startup % 1% 2% 3% 4% 5% 6% 7% 9

Changed:

Rem start java com. sun. web. shell. Startup % 1% 2% 3% 4% 5% 6% 7% 9

Java com. sun. web. shell. Startup % 1% 2% 3% 4% 5% 6% 7% 8% 9

If the old version of JDK1.2 is used, you do not need to modify startserver. bat. another DOS window will appear after execution.

A string is displayed after running, and endpoint created: localhost/127.0.0.1: 8080 is displayed. Indicates that the normal startup is completed. However, it does not support query of Chinese fields and Chinese values in the database.

Open a browser and enter http: // your machine IP address: 8080. then, the browser displays the vacant province page. on this page, you can view the Servlet example.
Java Servlet provides a Cookie class. its constructor has two parameters, representing the Cookie name and value respectively. The Cookie class provides various methods to set the Cookie attributes. for example, you can use the setMaxAge () method to set the Cookie survival time. If the survival time is negative, the browser closes the Cookie and disappears. If the survival time is 0, it indicates that the Cookie is deleted. if the survival time is positive, it indicates how many seconds the Cookie exists.

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.