jspÁ¬½ÓÊý¾Ý¿âʾÀý
1£¬Ð½¨Ò»web¹¤³Ì£¬½«Êý¾Ý¿âÁ¬½Ó°üÌí¼ÓÈëlibÎļþ¼ÐÏ¡£
2£¬Ð½¨jspÒ³Ãæ£¬ÄÚÈÝÈçÏ£º
<%@ page language="java" import="java.util.*" import="java.sql.*" pageEncoding="gb2312"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>jspÁ¬½ÓÊý¾Ý¿â</title>
</head>
<body>
This is my JSP page. <br>
<%
// Çý¶¯³ÌÐòÃû
String driver = "com.mysql.jdbc.Driver";
// URLÖ¸ÏòÒª·ÃÎʵÄÊý¾Ý¿âÃûscutcs
String url = "jdbc:mysql://192.168.10.43:3306/clientmanager";
// MySQLÅäÖÃʱµÄÓû§Ãû
String user = "root";
// MySQLÅäÖÃʱµÄÃÜÂë
String password = "123";
try {
// ¼ÓÔØÇý¶¯³ÌÐò
Class.forName(driver);
// Á¬ÐøÊý¾Ý¿â
Connection conn = DriverManager.getConnection(url, user, password);
if (!conn.isClosed())
System.out.println("Succeeded connecting to the Database!");
// statementÓÃÀ´Ö´ÐÐSQLÓï¾ä
Statement statement = conn.createStatement();
// ÒªÖ´ÐеÄSQLÓï¾ä
String sql = "select * from tb_hotel";
// ½á¹û¼¯
ResultSet rs = statement.executeQuery(sql);
System.out.println("-----------------");
System.out.println("Ö´Ðнá¹ûÈçÏÂËùʾ:");
System.out.println("-----------------");
String name = null;
while (rs.next()) {
// Ñ¡Ôñhotel_nameÕâÁÐÊý¾Ý
name = rs.getString("hotel_name");
// Êä³ö½á¹û
System.out.println("¾ÆµêÃû£º" + "\t" + name);
}
rs.close();
conn.close();
Ïà¹ØÎĵµ£º
JSPÄÚ½¨¶ÔÏó- -
¢Ù out - javax.servlet.jsp.jspWriter
out¶Ô ......
response.setContentType( "application/pdf" ); // MIME type for pdf doc
response.setHeader("Content-Disposition","attachment;filename=output.pdf;");
Sets the Content-Type header. Content-Type identifies the MIME type of the response document and the character set encoding.
To se ......
JSP¿ª·¢ÈëÃÅ
¸ÅÊö£º
JSP(Java Server Pages)ÊÇÓÉSun Microsystems¹«Ë¾³«µ¼¡¢Ðí¶à¹«Ë¾²ÎÓëÒ»Æð½¨Á¢µÄÒ»ÖÖ¶¯Ì¬ÍøÒ³¼¼Êõ±ê×¼¡£JSP¼¼ÊõÓеãÀàËÆASP¼¼Êõ£¬ËüÊÇÔÚ´«Í³µÄÍøÒ³HTMLÎļþ(*.htm,*.html)ÖвåÈëJava³ÌÐò¶Î(Scriptlet)ºÍJSP ±ê¼Ç(tag)£¬´Ó¶øÐγÉJSPÎļþ(*.jsp)¡£ ÓÃJSP¿ª·¢µÄWebÓ¦ÓÃÊÇ¿çÆ½Ì¨µÄ£¬¼ÈÄÜÔÚLinuxÏÂÔ ......
ÕªÒª£ºËäÈ»session»úÖÆÔÚwebÓ¦ÓóÌÐòÖб»²ÉÓÃÒѾºÜ³¤Ê±¼äÁË£¬µ«ÊÇÈÔÈ»ÓкܶàÈ˲»Çå³þsession»úÖÆµÄ±¾ÖÊ£¬ÒÔÖÁ²»ÄÜÕýÈ·µÄÓ¦ÓÃÕâÒ»¼¼Êõ¡£±¾ÎĽ«ÏêϸÌÖÂÛsessionµÄ¹¤×÷»úÖÆ²¢ÇÒ¶ÔÔÚJava web applicationÖÐÓ¦ÓÃsession»úÖÆÊ±³£¼ûµÄÎÊÌâ×÷³ö½â´ð¡£
Ŀ¼£º
Ò»¡¢ÊõÓïsession
¶þ¡¢HTTPÐÒéÓë״̬±£³Ö
Èý¡¢Àí½âcookie» ......
JSP¸ßÇåËõÂÔͼJMagickʹÓã¬ÊµÏÖÁ˶ÔͼƬµÄ¶àÖÖ²Ù×÷£¬ºÏ³ÉͼƬ£¬ËõÂÔͼ¡¢¸´ÖÆÊý¾ÝµÈµÈ...¡£
Ê×ÏÈÏÂÔØ£º
http://downloads.jmagick.org/6.3.9/ImageMagick-6.3.9-0-Q16-windows-dll.exe
http://downloads.jmagick.org/6.3.9/jmagick-win-6.3.9-Q16.zip
°²×°ImageMagick-6.3.9-0-Q16-windows-dll.exe³ÌÐòÔÚFÅÌÈ磺F:\Imag ......