Java servlet builds Java web development environment with MySQL _java

Source: Internet
Author: User
Tags learn php java web

This learning servlet database is MySQL, and I am now ready to learn javaweb, so the article on the Javaweb will continue to update, a few days ago, actually want to learn PHP, but the back of a friend's reminder, let me turn to the javaweb.

Because I am currently doing mobile phone application, so learn Java or intend to start from the data interface, this process will be very careful ... From the way I built-----mistakes-----> The final data show, I'll post it one by one.

First, install the Javaweb development environment under the Ecplise:

This step is the same as the previous one, so I'm just posting the address here, Javaservlet+oracle.

Http://www.jb51.net/article/77065.htm

Second, download Web server Software Apatch-tomcat 7.0:

Download the Java Web Server support software Apatch-tomcat, then unzip to any path,

In fact, I suggest that you can create a folder about the Java servlet to store files about it, because there are also. jar packages such files need to be placed, below is my folder

Iii. Creating a servlet Web server environment/creating a servlet Web project:

1: Add Web Server environment

Ecplise---> Menu bar (Windows--->preferences--->server--->runtime environment-->add

2: Create Web Dynamic Web site, add servlet page

Create a Web Dynamic Web site file----->new---->dynamic Web project Create and then directly next, jump after a random name on the finish created

Create a servlet page: Right-click the src----in the project >new--->servlet create a page

Here is the screenshot after creation:

In the screenshot above

One of the helper packages is the MySQL helper class, the second is the JSON helper class,

Inside the Servlettest package is a servlet page.

The dbinfo.properties file in the src folder is my own database connection auxiliary file, which you can create on the desktop and then copy to the SRC folder, remember that the path must not be wrong,

Otherwise, the database connection will be used to make an error. Here is a screenshot of this file, which is the information required for MySQL database connection

,

Here our Javaservlet project and the running environment are created well.

Iv. add the required. jar packages to the Apatch-tomcat 7.0 Lib folder:

Here I use only two jar packages, one is the MySQL driver package and the second is the JSON helper package. In order to detail, I still cut a picture.

Five, paste code screenshot, and run screenshots:

The 1:servlet page altogether has three methods, the first is the class constructs the way generally does not use, second and three are the data request processing method, one is get two is post, is to access the data the way to make the limit, relative get to the post is more secure, But they are the same for the person who writes the interface ...

Here are two helper packaged classes, Mysqlhelper and Resulttojsontool, in fact, Mysqlhelper also encapsulates the way to access stored procedures,, with out return parameters of the stored procedure access method, I have written before the interface, But the. NET technology used, for the writing interface is not the two things are really inefficient, with his perhaps you 10 SQL statements completed tasks, only need a stored procedure.

2: Output effect

Intend to learn Java, later free time to learn most will be used to see Java, so will continue to add on the Java article, and then will involve the installation of Linux to build javaweb operating environment.

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.