Ubuntu Build JSP Environment

Source: Internet
Author: User
Tags gz file

1. Install JDK

sudo apt-get install OPENJDK-6-JDK

2. Install Apache2

sudo apt-get install apache2

3. Install MySQL

(1) Installation

sudo apt-get install Mysql-sql

(2) Creating databases and tables

Mysql-uroot-p

4. Install Tomcat

(1) Installation

Download the tar.gz file in the core in the Http://tomcat.apache.org/download-60.cgi page, and after the decompression, remove the unpacked folder (renamed Apache) to the/usr/local.

(2) Start Tomcat

Perform/usr/local/apache/bin/startup.sh at terminal

5. Use JDBC in JSP to connect to MySQL database

(1) Download JDBC Driver

Www.mysql.com/downloads/looking for connectors, and then the left side of the page there are connector/j clicks will appear for the selection of tar.gz and zip file download (download. tar.gz file), download after the decompression.

(2) Configure connection files

Copy the Mysql-connector-java-5.1.18-bin.jar files from the mysql-connector-java-5.1.18 you just expanded to the installed JDK and the Lib folder under Tomcat:

Jdk:/usr/lib/jvm/java-6-openjdk/lib

tomcat:/usr/local/apache-tomcat-6.0.35/lib/

6. Test files

(1) Create test Site

Create a table of contents:/usr/local/apache/lib/apache/webapps/test

Copy the/usr/local/apache/lib/apache/webapps/root/web-inf directory to the/usr/local/apache/lib/apache/webapps/test.

(2) Create test file

Create file:/usr/local/apache/lib/apache/webapps/test/test.jsp

<%@ page contenttype= "text/html; Charset=utf-8 "import=" java.util.* "%>
<%@ page import= "java.sql.*"%>
<title>
Test
</title>
<body bgcolor= "#ffffff" >
<center>
<% out.print ("HelloWorld"); %>
</center>
</body>

7. View results:

In the browser address bar, enter: localhost:8080/test/test.jsp to see if the page shows the data in the corresponding database.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.