Under Windows 2000 integrated mysql4.0.13 to build JSP environments with Tomcat4.1.24

zhaozj2021-02-16  52

Title: WINDOWS2000 integrated mysql4.0.13 and Tomcat4.1.24 to build JSP environments

Author: hoxisoft (hoxisoft@263.net)

Date: 2003-06-20

Originally: In the vast Internet, there is no one in the latest mysql4.0.13 and the integrated configuration documentation of Tomcat4.1.24. In the rest of our own work, summarize the actual experience of the JSP environment and refer to previous version MySQL, Tomcat related configuration articles, write this configuration document. I hope to give the majority of beginners who like Java like me to make reference, in order to take a little more detours; the level is limited to the time, welcome ax!

table of Contents:

First, software preparation

Second, software installation

Third, the first configuration and test

Fourth, integrated configuration

Five, full line test

6. Supplementary description

Seven, thanks

Eight, explanation

Specific implementation steps:

First, software preparation:

Suppose you have a hard software environment that can run Win2000.

1.J2SDK1.4.1: Go to http://java.sun.com/j2se/1.4.1/download.html download;

2.Mysql4.0.13: to http://www.mysql.com download;

3.Tomcat4.1.24: to http://jakarta.apache.org/ download;

4.mm.mysql-2.0.4-bin.jar: to http://mysql.ihostunit.com/downloads/contrib/mm.mysql-2.0.4-bin.jar download;

Second, the software installation:

1. Install J2SDK:

Install according to the installation wizard (generally installed under C: /J2SDK1.4.1, easy to operate);

2. Install MySQL:

Install according to the installation wizard (select the installation directory to C: /, easy to operate; after the installation is successful, its path is: c: / mysql);

3. Install Tomcat:

Install according to the installation wizard (change the installation directory to c: /tomcat4.1, you will enter the password of Admin (system administrator);

4. Place the JDBC driver of MySQL:

Put mm.mysql-2.0.4-bin.jar files under C: /J2SDK1.4.0-RC/LIB (which should not do, it should not matter, mainly in system variables, but no A few people say it is good, so I will release it here);

Third, the first configuration and test:

For the first configuration of the software environment installed, and test its environment:

(1) Configuration - environment variable:

1. New system variable java_home, its value is: c: /j2sdk1.4.1 (if you don't press the above path installation, change to your installation path);

2. New system variable tomcat_home, its value is: c: / tomcat4 (if you don't press the above path installation, change to your installation path);

3. System variable ClassPath, added, its value is: c: / tomcat 4.1 / common / classes; c: / tomcat 4.1 / circume / lib

4. System variable ClassPath, added, its value is: C: /J2SDK1.4.0-RC/LIB/mm.mysql-2.0.4-bin;

(2) Test default service:

1. Please start Tomcat4.1 (in the start-program "to find the Apache Tomcat4.1 Run START Tomcat) service: Open the browser, type in the address bar: http: // localhost: 8080 Test: You can in the browser See the welcome interface of Tomcat. Description Tomcat works fine (note that the Tomcat default port is 8080, if there is other programs, please change);

2. Start the mysql service (MySQL service is started with the operating system by default, and Winmysqladmin.exe minimizes on the system tray):

Enter CMD, to the C: / MySQL / BIN directory, execute mysql, enter, normal, to output some welcome information, indicating that mysql works fine;

Fourth, integrated configuration:

Do the corresponding configuration for MySQL4 with Tomcat4, let them work together:

1. Copy mm.mysql-2.0.4-bin.jar to Tomcat's CommON / lib directory;

2. The test is normal; save the following code into Test.jsp to C: / tomcat 4.1 / webapps / root directory:

<% @ Page ContentType = "Text / HTML; Charset = GB2312"%> <% java.sql.connection conn; java.lang.string strconn; class.forname ("org.gjt.mm.mysql.driver). Newinstance (); conn = java.sql.driverManager.getConnection ("JDBC: mysql: // LocalHost / Test", "root", "");%> <% - here is a TEST with MYSQL4 The library, the user and the password are the default root and air -%>

3. Enter http: // localhost: 8080 / test.jsp in the browser's address, if the blank page appears, that is, the mysql4 is integrated with Tomcat4;

Five, full line test:

Start Tomcat4.1;

2. Establish a database and table;

First establish a table in MySQL and insert a few data. SQL code is as follows: Create Database test; - Run Use Test; - Run Create Talbe User (ID INT (4) Auto_Increment Primary Key, Name Varchar (20)); - Run Insert Into User (Name) VALUES ('Test '); - Run OK, you have established a database TEST to create a table User, and a record is inserted.

3, display the record in the database;

Save the following code into test2.jsp to c: / tomcat 4.1 / webApps / root directory: <% @ page contenttype = "text / html; charset = GBK"%> <% @ page language = "java" import = " Java.sql. * "%> <% connection conn = null; class.forname (" org.gjt.mm.mysql.driver). NewInstance (); conn = java.sql.driverManager.getConnection ("JDBC: mysql : // localhost / test "," root "," "); if (conn == null) {system.out.println (" get conn error ");} Statement Stmt = conn.createstatement (); ResultSet RS_RESULT = NULL;%> test </ title> </ head> <body> <% rs_result = stmt.executequery ("select * from user"); string name; while (rs_Result.next) )) {Name = rs_result.getstring ("name");%> <% = Name%> <%} rs_result.close (); stmt.close (); conn.close ();%> </ body> < / html> 4. Open your browser, enter http: // localhost: 8080 / test.jsp in the address bar, display Test on the page, that is, the read database is successful;</p> <p>6. Supplementary description:</p> <p>1. Suppose an item has a project in the E: / TEST / OA directory (including index.jsp and other JSP files and beans, such as WEB-INF / CLASSES / SERVLET, JAVABEAN); set Tomcat to support your project, open C: /TOMCAT4.1/conf/server.xml file, before "</ context>" before "</ context>", add <context path = "/ OA" debug = "0" DOCBASE = "E: / Test / OA "Reloadable =" True "/> and save. Description: Context (Represents a web application): DOCBASE defines the path to the application; Path represents the prefix of the URL of this web application, so the requested URL is http: // localhost: 8080 / oa; reloadable this property is very important, If TRUE, Tomcat automatically detects changes in the application's / web-inf / lib and / web-inf / class directory, automatic loading of modifications or new beans and servlets, we can see if you don't worry about Tomcat Go to the BEAN to bring the change of JSP;</p> <p>2. Start Tomcat4.1, enter http: // localhost: 8080 / OA in the browser's address, such as JSP and beans, etc., usually, you will generalize the content of your index.jsp / index.html file and display. Seven, thanks:</p> <p>1. Thank Apache, MySQL organization, provides you with a good free application server and database;</p> <p>2. Thank you for writing Tomcat3.x / Tomcat4. * Friends who configure documents, for your reference to this document today;</p> <p>8. Description:</p> <p>1. If you feel satisfied, I want to reprint or collect this article, I am very grateful, please indicate the author hoxisoft (hoxisoft@263.net)</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-25245.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="25245" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.046</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'W_2BuhJt0Y5YBYn2xgY3IEFY4Wyv9_2FYAFG2DL151g7lKWy7F1gtCjYYdR5VB77urjxxopY0XBmcKeawZqkyAJU9w_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>