First, software download:
1, Java
The 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, the installation version or the decompression version is OK.
3. Database
Recommended use mysql,but temporarily can not find the download address, because our class has curriculum design to use SQL Server, so the following practice will use SQL Server (find a Setup disk installation)
Note: three jar files (beginning with file name ms) are required to connect to SQL Server and can be downloaded from here:
Http://www.jb51.net/softs/234055.html
This includes the complete configuration method
Second, the Software installation:
1. Double-click the install JDK. After loading on my Computer-> properties-> Advanced-> environment variable-> system variable add the following environment variables:
(Assuming your JDK is installed in C:/JDK)
Jdk_home=c:jdk
Classpath=.; %jdk_home%libdt.jar;%jdk_home%libtools.jar
Added in path (already in existence):%jdk_home%bin
This allows the JDK environment to be configured successfully.
2. Double click to install your tomcat. (Recommended installation in D:/tomcat)
Note: The tomcat5.0.x version is available without configuring the environment variables, but if you need to compile the servlet you must put Tomcat's two jar files in the environment variables as follows:
Add in My Computer-> properties-> Advanced-> environment variable-> system variable:
Tomcat_home=d:tomcat
Modify classpath into:.; %jdk_home%libdt.jar;% jdk_home%libtools.jar;%tomcat_home%commonlibservlet-api.jar;%tomcat_home% Commonlibjsp-api.jar;
This has been fully installed Tomcat.
Recommendation: Add again in path:%jdk_home%bin;%tomcat_home%bin
The purpose of this is to use Tomcat's tools in virtual DOS
Finally, the three jar files downloaded from the first step are placed in the Common/lib directory under the Tomcat directory.
3. Test:
To open the Monitor tool for Tomcat (kitten pattern) in the Start menu, click Start Server to display the green triangle to start, open the browser in the address bar input: http://localhost:8080/can see the kitten pattern description has been configured successfully.
4. Installation database (SQL Server)
A personal or development version (personal recommended Personal Edition) must be installed under Windows XP.
Always next (Microsoft's stuff is convenient), here, notice that the domain account where the local account is selected, to the validation where the selection of mixed authentication (this is important, if you choose System authentication in the program will not be connected to the database), for your SA user input a password (if the practice is not to consider security, choose "Blank password" is OK)
Third, formal programming:
1. Establishing a Database
Open the Start menu to find the Enterprise Manager inside the SQL Server shortcut group, click on the left side of the tree generally have a localhost connection, if there is a green triangle symbol to prove that the database connection is successful. Click Mail to create a new database, create a new datasheet in your new database (for example, test), and set up several fields in the datasheet.
Add: Another way to build a table is to use SQL scripts to build tables. First create the following file:
Copy 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 SQL Server shortcut group on the Start menu, click on "File"-"open", select Test.sql, click Run.
2. Create Tomcat virtual directory
Create a folder in any place you like (for example, E:/wool), create a Web-inf folder in a folder (note that you have to capitalize), set up classes and Lib two folders in the Web-inf folder, and put the three jar files (connected to the database) that you downloaded in the first step Lib folder. (Some people may ask: "Why there is no web.xml this document, not urgent, will be said later)
3. configuration file and connection pool
This class to do course design This step baffled many students, I have the easiest way here (my teacher suggested to go to the http://localhost:8080/admin to configure, I personally think that trouble and error prone), OK, the following steps:
First, create two files by following:
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: In the process of helping the classmate to find a problem, the configuration file above must delete the annotation part to run successfully. For the moment, there is no reason why, theoretically, such annotations in the XML file are allowed, depressing.
Xml
Connectdb
Jdbc/sqlserver
Javax.sql.DataSource
Container
After two files have been created, place the wool.xml in the Confcatalinalocalhost in the Tomcat directory and web.xml files into the E:woolweb-inf directory.
4. Write Segment Program Test connection
test.jsp
Name Sex score
Put the test.jsp file in the E:wool.
5. Start SQL Server and Tomcat, enter in browser:
http://localhost:8080/wool/test.jsp
Four, write in the last
The above method is the method that I used to help my classmate to configure the project training (web three layer architecture) recently, it is the best way that I used to refer to the experience of prawns on the network. With these steps, you can get started quickly for students who have not done Java or other web-based programming (in fact, the most important thing is to complete this annoying engineering training).