Java Web project development: Eclipse EE + Tomcat + MySQL

Source: Internet
Author: User

Download: Select 32-bit or 64-bit based on the computer's operating system. Tomcat is a Java project, so install JDK (JRE) before running tomcat ). For Windows operating systems, you can select the ZIP or installer version in core.

 

The installer version may fail because the previous tomcat version is not uninstalled and the historical Tomcat service is still starting. Enter the command "SC Delete tomcat6" on the doscommand line to uninstall the historical Service (if the corresponding command of tomcatx version is SC Delete tomcatx ).

 

If the zip version does not start the Tomcat service in Windows by default. To run tomcat, go to the tomcat/bin directory under DOS and run the command "service. Bat install ". You can use bin/tomcat6w.exe to enable and disable the Tomcat service only after installing the service.

 

You can use startup. BAT and shutdown. bat under bin/to enable and disable tomcat.

 

Eclipse EE (not myeclipse) can be used to develop Java Web projects. To add a Tomcat server to eclipse, follow these steps: window-preference-server-runtime environment-add ....... After the service is added, eclipse automatically generates a servers project. Note that if tomcat in external Tomcat and eclipse is a tomcat, you cannot enable Tomcat both inside and outside. If the port is opened outside, tomcat in it will prompt that the port is occupied. If eclipse Tomcat is opened, the external Tomcat cannot be opened.

Now you can develop Java Web projects in Eclipse. When creating a Web Project, you generally choose to create a Dynamic Web Project. After the project is completed, it is RunAs-Run On Server. You can configure the Tomcat Server if it is not attached to a project. Change Server Location to Use Tomcat installation and Deploy Path to webapps, so the Web Project program developed by Eclipse will be placed under the default tomcat/webapps of the system tomcat. The advantage of this is that browsers inside and outside Eclipse can access web projects, otherwise external browsers cannot access tomcat. When such a configuration is applied, the tomcat configuration file corresponding to the Servers project is consistent with that of the external tomcat configuration file. You can modify the tomcat server configuration in Eclipse.

 

You can modify the tomcat-users.xml for tomcat under Servers in Eclipse and add statements

<Role rolename = "manager-gui"/> <user username = "tomcat" password = "s3cret" roles = "manager-gui"/>

To add a tomcat Administrator Account to monitor the running status of the tomcat server. If you modify the configuration file in the system tomcat/conf, Eclipse will automatically overwrite the configuration file in tomcat/conf with the tomcat configuration file under Servers.

 

In addition, before creating a JSP file in a Web project, if the JSP file contains Chinese characters, select UTF-8 or Chinese, National Standard in Window-Preferences-Web-JSP Files-Encoding.

 

When JSTL is used in JSP

<% @ Taglib prefix = "C" uri = "http://java.sun.com/jsp/jstl/core" %>

Add to code. If the WEB-INF/lib does not have jstl. jar and standard. jar, a prompt is displayed.

Can not find the tag library descriptor for "http://java.sun.com/jsp/jstl/core"

. You can copy the two jars to the current project WEB-INF/lib at tomcat/webapps \ examples \ WEB-INF \ Lib.


When developing a servlet, you can create a servlet under the SRC of the Java code. In addition, you need to copy the servlet-api.jar from tomcat/lib to the project's WEB-INF/lib.


MySQL installation is not required. To connect to the MySQL database in a Java project, go to the import mysql-connector-java-xxx-bin.jar (which can be downloaded from the MySQL official website ). In a Java Web project, if you want to connect to the MySQL database in Java resources, import the connection package here. If you want to access the database through the Tomcat Service webpage, copy the connection package to Tomcat/lib.

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.