整合Apache+Tomcat+MySQL_MySQL
ApacheTomcat
一、整合Apache+Tomcat服务器
1. 复制mod_jk_1.2.5_2.0.47.dll文件到C:/Apache2/modules目录。
2. Apache配置:
C:/apahce2/conf/httpd.conf
httpd.conf
在此配置文件最后添加以下语句,用以支持jsp程序:
LoadModule jk_module modules/mod_jk_1.2.5_2.0.47.dll
JkWorkersFile "C:/Tomcat 5.0/conf/workers.properties"
JkMount /servlet/* ajp13
JkMount /*.jsp ajp13
3. 查看C:/Tomcat 5.0/conf/server.xml文件中有关端口“8009”是否被注释,如果是和我这的版本一致的话,不用修改。
4. 在C:/Tomcat 5.0/conf/目录下,新建文件名为“workers.properties”的文件,将如下内容复制到新建文件workers.properties中。
workers.properties
# 只复制以下内容即可:
# 这现行根据安装目录做修改
workers.tomcat_home=C:/Tomcat 5.0
workers.java_home=C:/j2sdk1.4.1_01
ps=/
# worker.list=ajp13
worker.list=ajp12,ajp13
worker.ajp12.port=8007
worker.ajp12.host=localhost
worker.ajp12.type=ajp12
worker.ajp12.lbfactor=1
worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13
worker.ajp13.lbfactor=1
worker.loadbalancer.type=lb
worker.loadbalancer.balanced_workers=ajp12, ajp13
worker.inprocess.type=jni
worker.inprocess.class_path=$(workers.tomcat_home)$(ps)classes
worker.inprocess.class_path=$(workers.tomcat_home)$(ps)lib$(ps)jaxp.jar
worker.inprocess.class_path=$(workers.tomcat_home)$(ps)lib$(ps)parser.jar
worker.inprocess.class_path=$(workers.tomcat_home)$(ps)common$(ps)lib$(ps)jasper.jar
worker.inprocess.class_path=$(workers.tomcat_home)$(ps)common$(ps)lib$(ps)servlet.jar
worker.inprocess.class_path=$(workers.tomcat_home)$(ps)common$(ps)lib$(ps)webserver.jar
worker.inprocess.class_path=$(workers.java_home)$(ps)lib$(ps)tools.jar
worker.inprocess.cmd_line=-config
worker.inprocess.cmd_line=$(workers.tomcat_home)/conf/jni_server.xml
worker.inprocess.cmd_line=-home
worker.inprocess.cmd_line=$(workers.tomcat_home)
worker.inprocess.jvm_lib=$(workers.java_home)$(ps)jre$(ps)bin$(ps)classic$(ps)jvm.dll
worker.inprocess.stdout=$(workers.tomcat_home)$(ps)inprocess.stdout
worker.inprocess.stderr=$(workers.tomcat_home)$(ps)inprocess.stderr
worker.inprocess.sysprops=tomcat.home=$(workers.tomcat_home)
5. 到此Apache 和 Tomcat整合完成,重启Apache和Tomcat服务器,
用编辑器编写如下内容:
String Msg = "This is JSP test! 看到这段话,恭喜你,成功了!";
out.print("Hello World!");
%>
The current date and time is
String str = "Using trim() and substring() can be very useful";
out.println(str);
%>
保存文件名为“test.jsp”到C:/Tomcat 5.0/webapps/ROOT目录,然后打开浏览器,浏览:http://localhost:8080/test.jsp,如果显示正常,然后将地址改为:http://localhost/test.jsp 显示正常说明配置成功。严格按以上说明安装配置,都会一次成功。
如果想更改tomcat的文档路径,
二、整合Apache+Tomcat+MySQL
这步相对简单许多,但也是最不容易成功的部分,前面已经将JSP的MySQL驱动放到相应的目录中,环境变量也设置,所以只是测试JSP是否可以连接MySQL数据库。
1. 测试1,用编辑器编写如下内容:
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","");
%>
注:数据库此处为:test 连接数据库存的用户名为:root 密码为空。根据自己数据库作相应修改。
保存文件名为“test-mysql.jsp”到C:/Tomcat 5.0/webapps/ROOT目录,然后打开浏览器,浏览:http://localhost:8080/test-mysql.jsp 或 http://localhost/test-mysql.jsp ,运行后,如果显示为空白页面,说明连接数据库成功,否则说明没有连接成功,请往回逐步仔细配置。
2. 测试2,用编辑器编写如下内容:
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;
%>
RS_result=stmt.executeQuery("select * from guestbook");
String Name;
while(RS_result.next())
{
Name=RS_result.getString("name");
%>
}
RS_result.close();
stmt.close();
conn.close();
%>
保存文件名为“test-mysql2.jsp”到C:/Tomcat 5.0/webapps/ROOT目录,然后打开浏览器,浏览:http://localhost:8080/test-mysql2.jsp 或 http://localhost/test-mysql2.jsp

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The default map on the iPhone is Maps, Apple's proprietary geolocation provider. Although the map is getting better, it doesn't work well outside the United States. It has nothing to offer compared to Google Maps. In this article, we discuss the feasible steps to use Google Maps to become the default map on your iPhone. How to Make Google Maps the Default Map in iPhone Setting Google Maps as the default map app on your phone is easier than you think. Follow the steps below – Prerequisite steps – You must have Gmail installed on your phone. Step 1 – Open the AppStore. Step 2 – Search for “Gmail”. Step 3 – Click next to Gmail app

Solution: 1. Check the eMule settings to make sure you have entered the correct server address and port number; 2. Check the network connection, make sure the computer is connected to the Internet, and reset the router; 3. Check whether the server is online. If your settings are If there is no problem with the network connection, you need to check whether the server is online; 4. Update the eMule version, visit the eMule official website, and download the latest version of the eMule software; 5. Seek help.

As a LINUX user, we often need to install various software and servers on CentOS. This article will introduce in detail how to install fuse and set up a server on CentOS to help you complete the related operations smoothly. CentOS installation fuseFuse is a user space file system framework that allows unprivileged users to access and operate the file system through a customized file system. Installing fuse on CentOS is very simple, just follow the following steps: 1. Open the terminal and Log in as root user. 2. Use the following command to install the fuse package: ```yuminstallfuse3. Confirm the prompts during the installation process and enter `y` to continue. 4. Installation completed

What should I do if the RPC server is unavailable and cannot be accessed on the desktop? In recent years, computers and the Internet have penetrated into every corner of our lives. As a technology for centralized computing and resource sharing, Remote Procedure Call (RPC) plays a vital role in network communication. However, sometimes we may encounter a situation where the RPC server is unavailable, resulting in the inability to enter the desktop. This article will describe some of the possible causes of this problem and provide solutions. First, we need to understand why the RPC server is unavailable. RPC server is a

Is the clock app missing from your phone? The date and time will still appear on your iPhone's status bar. However, without the Clock app, you won’t be able to use world clock, stopwatch, alarm clock, and many other features. Therefore, fixing missing clock app should be at the top of your to-do list. These solutions can help you resolve this issue. Fix 1 – Place the Clock App If you mistakenly removed the Clock app from your home screen, you can put the Clock app back in its place. Step 1 – Unlock your iPhone and start swiping to the left until you reach the App Library page. Step 2 – Next, search for “clock” in the search box. Step 3 – When you see “Clock” below in the search results, press and hold it and

The role of a DHCP relay is to forward received DHCP packets to another DHCP server on the network, even if the two servers are on different subnets. By using a DHCP relay, you can deploy a centralized DHCP server in the network center and use it to dynamically assign IP addresses to all network subnets/VLANs. Dnsmasq is a commonly used DNS and DHCP protocol server that can be configured as a DHCP relay server to help manage dynamic host configurations in the network. In this article, we will show you how to configure dnsmasq as a DHCP relay server. Content Topics: Network Topology Configuring Static IP Addresses on a DHCP Relay D on a Centralized DHCP Server

In network data transmission, IP proxy servers play an important role, helping users hide their real IP addresses, protect privacy, and improve access speeds. In this article, we will introduce the best practice guide on how to build an IP proxy server with PHP and provide specific code examples. What is an IP proxy server? An IP proxy server is an intermediate server located between the user and the target server. It acts as a transfer station between the user and the target server, forwarding the user's requests and responses. By using an IP proxy server

Are you getting "Unable to allow access to camera and microphone" when trying to use the app? Typically, you grant camera and microphone permissions to specific people on a need-to-provide basis. However, if you deny permission, the camera and microphone will not work and will display this error message instead. Solving this problem is very basic and you can do it in a minute or two. Fix 1 – Provide Camera, Microphone Permissions You can provide the necessary camera and microphone permissions directly in settings. Step 1 – Go to the Settings tab. Step 2 – Open the Privacy & Security panel. Step 3 – Turn on the “Camera” permission there. Step 4 – Inside, you will find a list of apps that have requested permission for your phone’s camera. Step 5 – Open the “Camera” of the specified app
