JSPÖÐÀûÓÃÊý¾ÝÔ´¶ÔÏó½¨Á¢Êý¾Ý¿âÁ¬½Ó
ÅäÖóÌÐòµÄÔËÐÐĿ¼ÓëJDBCÊý¾ÝÔ´:
<Context path="/test" docBase="F:\JSPLesson\test" reloadable="true">
<Resource name="jdbc/bookstore" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="root" password="123456"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/bookstore?autoReconnect=true"/>
</Context>
JSPÖÐͨ¹ýÈçÏ·½Ê½µÃµ½Êý¾Ý¿âÁ¬½Ó:
<%
Context ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/bookstore");
Connection conn = ds.getConnection();
%>
Ïà¹ØÎĵµ£º
index.jsp:
<html>
<head>
<title>The News</title>
</head>
<body>
<h1> Latest News</h1>
<table>
<tr>
<td><h3><%@include file="items/news1.jsp" %></h3></td>
</tr>
<tr>
<td> ......
1 £©Ê×ÏȽ¨Á¢¹ÜÀíÓû§±í£¬ÆäÖÐ UserPopedom ¼Ç¼Óû§µÄȨÏÞ×Ö·û£¬ÆäʵҲ¾ÍÊÇһЩ JSP »òÕß ACTION µÄÎļþÃû£º
CREATE TABLE [dbo].[AdminUser] (
[UserID] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[UserName] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[UserPass] [varchar ......
×¢ÊÍ
ÔÚ¿Í»§¶ËÏÔʾһ¸ö×¢ÊÍ.
JSP Óï·¨
<!-- comment [ <%= expression %> ] -->
Àý×Ó 1
<!-- This file displays the user login screen -->
ÔÚ¿Í»§¶ËµÄHTMLÔ´´úÂëÖвúÉúºÍÉÏÃæÒ»ÑùµÄÊý¾Ý£º
<!-- This file displays the user login screen -->
Àý×Ó 2
<!-- This page was lo ......
1. RequestDispatcher.forward()
ÊÇÔÚ·þÎñÆ÷¶ËÆð×÷ÓÃ,µ±Ê¹ÓÃforward()ʱ,Servlet engine´«µÝHTTPÇëÇó´Óµ±Ç°µÄServlet or JSPµ½ÁíÍâÒ»¸öServlet,JSP »òÆÕͨHTMLÎļþ,Ò²¼´ÄãµÄformÌá½»ÖÁa.jsp,ÔÚa.jspÓõ½ÁËforward()ÖØ¶¨ÏòÖÁb.jsp,´ËʱformÌá½»µÄËùÓÐÐÅÏ¢ÔÚ b.jsp¶¼¿ÉÒÔ»ñµÃ,²ÎÊý×Ô¶¯´«µÝ. µ«fo ......
jspÂÒÂëÎÊÌâ½â¾ö
1¡¢Ò»°ãµÄjspÒ³ÃæÏÔʾÂÒÂë
<%@ page contentType="text/html; charset=UTF-8"%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
2¡¢±íµ¥Ìá½»ÖÐÎÄʱ³öÏÖÂÒÂë
Èç¹ûjspÌá½»Ó¢ÎÄ×Ö·ûÄÜÕýÈ·ÏÔʾ£¬¶øÌá½»ÖÐÎÄʱ¾Í»á³öÏÖÂÒÂë¡£
ÔÒò£ºä ......