1. Software download:
1.java
jdk1.4.2 is used here.
Download address: http://dlc.sun.com/jdk/j2sdk-1_4_2_07-windows-i586-p.exe;
2. tomcat 5.0.28
The version of tomcat here is 5.0, and the installation version or the decompressed version are both acceptable.
3. Database
It is recommended to use mysql, but the download address cannot be found at the moment. Since our class has a course design this time that uses sqlserver, so the following practice will use sqlserver (find an installation disk to install)
Note: Three jar files (filename starting with ms) are required to connect to sqlserver, which can be downloaded from here:
//www.VeVB.COm/softs/234055.html
The above includes the complete configuration method
2. Software installation:
1. Double-click to install jdk. After installation, add the following environment variables in My Computer->Properties->Advanced->Environment Variables->System Variables:
(Assuming your JDK is installed in c:/jdk)
JDK_HOME=C:jdk
classpath=.;%JDK_HOME%libdt.jar;%JDK_HOME%libtools.jar
Add: %JDK_HOME%bin to PATH (which already exists)
In this way, the jdk environment is configured successfully.
2. Double-click to install your Tomcat. (It is recommended to install it in D:/tomcat)
Note: Tomcat5.0.x version can be used without configuring environment variables, but if you need to compile Servlet, you must also put the two jar files of tomcat into the environment variables. The specific method is as follows:
Add in My Computer->Properties->Advanced->Environment Variables->System Variables:
TOMCAT_HOME=D:tomcat
Modify the classpath to become: .;%JDK_HOME%libdt.jar;% JDK_HOME%libtools.jar;%TOMCAT_HOME%commonlibservlet-api.jar;%TOMCAT_HOME%commonlibjsp-api.jar;
This completes the installation of Tomcat.
Suggestion: Add: %JDK_HOME%bin;%TOMCAT_HOME%bin to PATH
The purpose of this is to use tomcat tools in virtual dos. Finally, put the three jar files downloaded in the first step into the common/lib directory under the tomcat directory.
3. Test:
Open the monitor tool of tomcat (cat pattern) in the start menu, click start server, and the green triangle is displayed to start. Open the browser and enter: http://localhost:8080/ in the address bar. You can see that the cat pattern description has been started. Configuration successful.
4. Install database (sqlserver)
Under Windows XP, the personal version or development version must be installed (I personally recommend the personal version).
Just keep going to next (Microsoft stuff is convenient). Note here that you select the local account for the domain account, and select hybrid verification for the verification (this is very important. If you choose system authentication, you will not be able to connect to the database in the program). Enter a password for your sa user (if you are practicing, you don’t need to consider security, just choose "empty password")
3. Formal programming:
1. Create a database
Open the start menu and find the Enterprise Manager in the shortcut group of sqlserver. Click on the tree on the left and there will usually be a localhost connection. If there is a green triangle symbol, it proves that the database connection is successful. Click the email to create a new database, and create a new data table (for example, called test) in your new database. Create several fields in the data table.
Supplement: Another way to create a table is to use a sql script to create a table. First create the following file:
Copy the code code as follows:
test.sql
create database test
USE test
create table test
(
id int not null identity(1,1),
mark varchar(255),
name varchar(255),
sex varchar(255)
)
Then open the Query Analyzer in the sqlserver shortcut group in the start menu, click "File" - "Open", select test.sql, and click Run.
2. Create a tomcat virtual directory
Create a folder anywhere you like (for example, e:/wool), create a WEB-INF folder in the folder (note that it must be capitalized), and create two folders, classes and lib, in the WEB-INF folder. Put the three jar files (used to connect to the database) downloaded in the first step into the lib folder. (Some people may ask: Why is there no web.xml file here? Don’t worry, I will talk about it later)
3. Configuration files and connection pools
This time, the course design step in the class stumped many students. Here is the simplest method (my teacher suggested going to http://localhost:8080/admin to configure it. I personally think that is troublesome and error-prone). Okay. , the following steps are introduced:
First, create two files as follows:
wool.xml
driverClassName
com.microsoft.jdbc.sqlserver.SQLServerDriver
url
jdbc:microsoft:sqlserver://localhost;DatabaseName=test
username
sa
password
>
maxActive
4
maxWait
5000
maxIdle
2
Note: I discovered a problem during the configuration process for my classmates, that is, the above configuration file must delete the comment part before it can run successfully. I don’t know the reason yet, but theoretically such comments are allowed in xml files, which is frustrating.
web.xml
connectDB
jdbc/sqlserver
javax.sql.DataSource
Container
After creating the two files, place wool.xml in confCatalinalocalhost in the tomcat directory; place the web.xml file in the E:woolWEB-INF directory.
4. Write a program to test the connection
test.jsp
For the name gender score, just place the test.jsp file in E:wool.
5. Start sqlserver and tomcat and enter in the browser:
http://localhost:8080/wool/test.jsp
4. Write at the end
The above method is the method I used recently when I helped my classmates configure engineering training (web three-tier architecture). It is the method I thought was the best after referring to the experience of prawns on the Internet. Through the above steps, students who have never done Java or other web-based programming can quickly get started (in fact, the most important thing is to complete this annoying engineering training).