[Linux] deploy the JSP development environment in Ubuntu. Eclipse + Mysql + JDBC and ubuntueclipse

Source: Internet
Author: User

[Linux] deploy the JSP development environment in Ubuntu. Eclipse + Mysql + JDBC and ubuntueclipse

The configuration of this item in Linux is similar to that in Windows. In the JSP development environment of Windows, configure Myeclipse6.5 + JDK1.6 + Tomcat6.0 + SVN1.8 in the front-end development environment of Javaweb (click to open the link), and configure the background environment, how to configure Mysql in Linux?

First, install JDK 1.7 in the same way as Debian JDK1.7 in [Linux] and Linux Java Helloworld (click to open the link. Then, you can get an Eclipse for JavaEE program just like installing Eclipse and Helloworld In Ubuntu (click to open the link.

Then, enter Ctrl + Alt + T to open the terminal, and enter the following command, which is the same as running M -- Mysql in LAMP to improve the Mysql service. Enter the command, wait for download, set the database password, and wait for installation. For details, refer to the previous "[Linux] layout the LAMP environment in Ubuntu" (click to open the link ).

sudo apt-get install mysql-server mysql-client

Later, like the second part in "Graphical LAMP development environment in Ubuntu" (click to open the link), we will do a good job of Mysql WorkBench to make Mysql graphical.

In Linux, php is deployed in the same way as jsp in many places, especially the same database Mysql.

Next, there are different aspects of Jsp and php.


1. Download and install Tomcat, and configure and deploy Tomcat in Eclipse

1. First, we need a Tomcat. Go to Tomcat's official website http://tomcat.apache.org/download-70.cgiand select the Linux version of Tomcat7.0's Core version.


2. decompress the package directly to the main folder to facilitate management without changing the file permissions. Delete the decompressed file. In fact, after decompression, the items in Tomcat are exactly the same as those in Windows. If you start Tomcat manually, use. sh to start and close Tomcat.


3. Open the Java EE interface under Eclipse, right-click the blank area on the Server Tab below, and add a Server.


4. Find Tomcat7 and click Next.


5. Then, in the browsing process, select the Tomcat path, which is the place we just decompressed. Then remember to select JRE for jdk1.7. Do not use the default JDK of Eclipse, or you will not know what the problem will be.


6. Later, because there is no Java Web project, you can directly choose to complete it.


7. Double-click the server we just created and configure Tomcat, to avoid problems encountered in [Java Web] compiling webapps under project Tomcat in Eclipse for JavaEE but there is no solution "(click to open the link.


8. In the open window, set the "Use Tomcat Installation (...)" field to "Server Locations (...) then, the compiled server will change. Then, change the Deploy Path to the default webapps of Tomcat, save the settings, and close the button.



2. Create a JavaEE project to connect to the Mysql database

1. Create a JavaEE Project, and create a Dynamic Web Project in the blank area of the Project Explorer tab on the left.


2. enter the name of the JavaWeb project, such as javawebtest. Click Next. Do not click Finish in a hurry.


3. As the Web project created in [Javaweb] Eclipse for JavaEE automatically generates the web. xml (click to open the link) to automatically generate the web. to enable the Java Web project to start directly.


4, after, we want to download a mysql-connector-java-5.0.8-bin.jar thing, put the lib under the WEB-INF under WebContent, so that the Web project can connect to the Mysql database. This is also an official Mysql file. Directly open its official website http://dev.mysql.com/downloads/connector/j/5.0.html (click to open the link) This official website is doing very bad, if the speed is not good, the drop-down menu is not responding. Select the old version, and then select a non-platform dependent version. Ubuntu can also decompress the zip file.


5, unzip, although there are a lot of documents, but as long as the mysql-connector-java-5.0.8-bin.jar in the Java Web project under the WebContent \ WEB-INF \ lib folder can be.


6. Refresh the javawebtest project under the Eclipse project and create a jsp file under the webcontent folder.


7. Name it test. jsp. Click here to complete it.


8. Write the following code in it:

<% @ Page language = "java" contentType = "text/html; charset = UTF-8" pageEncoding = "UTF-8" %> <% @ page import = "java. SQL. * "%> <! DOCTYPE html PUBLIC "-// W3C // dtd html 4.01 Transitional // EN" "http://www.w3.org/TR/html4/loose.dtd"> It is actually the content of connecting java to the Mysql database. Pay attention to introducing java in the header. SQL. * For details, see add, delete, modify, and query Mysql Databases in [Mysql] Java and the Java System class (click to open the link ). After writing the code, right-click the Tomcat Server under the Server and choose add project.


9. Add the javawebtest project to Tomcat and start the Tomcat server.


10. When you see the prompt that Tomcat is successfully started on the console, you can open the built-in wild fox Zen browser.


11. Enter localhost: 8080/javawebtest/test. if jsp displays "Database Link succeeded", it indicates that the JSP development environment has been successfully deployed in Ubuntu, And the JSP project can be successfully connected to the 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.