Building a JSP development environment under Windows

Source: Internet
Author: User

1. Configuration instructions:

+ = Editor: Eclipse (Java EE IDE)

= = database: MySQL (MySQL Workbench for database management, with MySQL connector/j connection)

= = Server: Tomcat

2. Eclipse is the green version, do not need to install, can put some plug-ins for easy development

3. Tomcat needs to configure the environment variable, which is the bin directory, which has scripts for operations such as startup and shutdown on various platforms. Do not open it manually or there may be port conflicts when eclipse is running

4. Eclipse needs to add the Tomcat server as instructed when creating a new Dynamic Web site

5. MySQL connector/j will have a jar file under C/program file (/x86) after installation to import the project's build path. Otherwise, you may get an error when you import JDBC driver.

Note The password is set when MySQL is installed, as well as the default font (utf-8 default collation is selected)

Template code: (Create the corresponding schema and table in the database first)

<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "pageencoding= "Utf-8"%><%@ pageImport= "Com.mysql.jdbc.Driver"%><%@ pageImport= "Java.sql.*"%><%//driver nameString drivername = "Com.mysql.jdbc.Driver";//Database user nameString uname = "root";//PasswordString Upassword = "Roger";//Table nameString tableName = "Person";//Database nameString dbName = "Roger";//URLString url = "jdbc:mysql://localhost/" +dbname+ "? user=" +uname+ "&password=" +Upassword; Class.forName ("Com.mysql.jdbc.Driver"). newinstance (); Connection Conn=drivermanager.getconnection (URL); Statement stmt=conn.createstatement (); String SQL= "SELECT * from" +TableName; ResultSet RS=stmt.executequery (SQL);//get the number of columns in a datasetResultSetMetaData RSMD =Rs.getmetadata ();intIcolumns =Rsmd.getcolumncount (); Out.print ("<table border=1><tr>"); for(inti=1;i<icolumns;++i) {Out.print ("<td>" +rsmd.getcatalogname (i) + "</td>");} Out.print ("</tr>"); while(Rs.next ()) {Out.print ("<tr>");  for(inti=1;i<icolumns;++i) {Out.print ("<td>" +rs.getstring (i) + "</td>"); } out.print ("</tr>");} Out.print ("</table>"); Out.print ("Success!"); Rs.close (); Stmt.close (); Conn.close ();%><! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >

Results:

The code above may have other problems, at least the whole process is going through!

Building a JSP development environment under Windows

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.