2013年6月15日 星期六

jsp include 範例

<%@ page contentType="text/html; charset=Big5" %>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=big5">
<title>include的使用範列</title>
</head>

<body>
<font color="yellow">
<p>這是一個密碼檢查程式</p>

<jsp:include page="a1.jsp">
<jsp:param name="username" value="hyh" />
<jsp:param name="password" value="123456" />
</jsp:include>

<p>include之後的顯示,前面內容是include進來的</p>
<p>主網頁的內容顯示</p>
</font>
</body>

</html>

=================================================
<%@ page contentType="text/html; charset=Big5" %>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=big5">
<title>密碼檢查程式</title>
</head>
<body>
<%
String username = request.getParameter("username");
String password = request.getParameter("password");

if (username.equals("hyh")) out.println("使用者名稱正確<br>");
else out.println("使用者名稱錯誤<br>");
if (password.equals("123456")) out.println("密碼正確<br>");
else out.println("密碼錯誤<br>");
%>
<p>返回主程式</p>
</body>
</html>


ref :  Here

沒有留言:

張貼留言