1 install Tomcat configuration environment
Tomcat 1.1 introduction
Tomcat server is a free open source Web application server, belongs to a lightweight application server, in small and medium system and concurrent access to the user is not a lot of cases are commonly used, is the first selection of development and debugging JSP program,
Tomcat 1.2 installation
1.2.1 installed version
After download and install version, click next, and all the way direct installation is successful, configure the environment variables for
The installation directory for the TOMCAT_HOME you
The CATALINA_HOME your installation directory
This is the simplest installation method, and then go to the website to download the Administration Web Application, extract directly to the installation directory, can use directly,
1.2.2 decompressed version
Modify the bin \ startup. Bat file:
In front of the first line to join the following two lines -
SET the JAVA_HOME=(JDK directory)
SET the CATALINA_HOME=(after decompression in front of the Tomcat directory)
If you need to use shutdown. Bat shut down the server, also in accordance with the above to join the two lines,
So, run startup. Bat you can run the server, run the shutdown. The bat can shut down the server
1.3 setup Tomcat user name and password
Into the Tomcat directory: TOMCAT_HOME \ conf \ Tomcat - users XML
Modify tomcat - users. XML:
In & lt; Tomcat - users> Node add:
Run startup. Bat start the service
Open a web browser, enter the address: http://localhost:8080/
Single machine on the left side of the Tomcat Manager link, input set the user name and password
Data source configuration 2
XML files
2.1 configuration context.Enter the directory: TOMCAT_HOME \ conf, open context. The XML file, in & lt; Context> Add nodes:
Name="JDBC/GBaseDB
"Type="javax.mail. SQL. The DataSource"
Auth="Container"
//password to cluster the user password
Password="111111"
//driverClassName driver name
DriverClassName="com. Gbase. JDBC Driver"
MaxIdle="10"
MaxWait="10000"
InitialSize="10"
//username to cluster user
The username="gbase"
//url for the connection string, including the connection of the cluster nodes IP, port and need to access the database
Url="JDBC: gbase://192.168.5.6:5258/test", "
MaxActive="100"/& gt;
2.2 configuration web. XML file
Enter the directory: TOMCAT_HOME \ webapps \ \ WEB WEB applications - INF, open the WEB. The XML file, in & lt; Web - app> Add nodes:
//res - ref - name must be with the web. In the XML & lt; Res - ref - name> Consistent
2.3 add database driver files
Copies the JDBC driver to the Tomcat lib directory
3 test connection
3.1 the new application under the TOMCAT_HOME \ webapps directory: GBaseTest
3.2 the TOMCAT_HOME \ webapps \ GBaseTest new directory under the WEB - INF
//must exist in the directory
3.3 in TOMCAT_HOME \ webapps \ GBaseTest \ WEB - under the INF new directory:
Class
Lib
//directory must exist, one in the class and can be null in the lib
3.4 in TOMCAT_HOME \ webapps \ GBaseTest \ WEB - newly built under the INF file:
Web.xml (i.e. steps of web 2.2, XML)
//advice from other webapps directory copy
3.5 under the TOMCAT_HOME \ webapps \ GBaseTest file: new connectTest. JSP
//new notepad file rename to
3.6 the connectTest. Add the following code in a JSP:
//the following Java code in blue highlight logo
<% @ page language="Java" import="javax.mail. SQL. *, Java, SQL *, javax.mail. Naming. *" contentType="text/HTML. GBK charset="% & gt;
<body>
//& lt; % % markers for Java code & gt;
<%
Try {
The Context initCtx=new InitialContext ();
//get the XML configuration file JDBC/GBaseDB associated data source object
The DataSource ds1=(DataSource) initCtx
Lookup (" Java: comp/env/JDBC/GBaseDB ");
//access to the database connection object
The Connection conn=an getConnection ();
% & gt;
//& lt; % % & gt; External to HTML code
<%
//will link back to the database connection pool
conn.close();
% & gt;
<%
} the catch (Exception e) {
//output exception information
Out.println (e. oString ());
}
% & gt;