发布于 2016-08-14 12:27:26 | 119 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的JSP由浅入深,程序狗速度看过来!

JSP JAVA公司的WEB开发编程语言

JSP全名为Java Server Pages - java服务器页面是由Sun Microsystems公司倡导、许多公司参与一起建立的一种动态网页技术标准。JSP技术有点类似ASP技术,它是在传统的网页HTML(标准通用标记语言的子集)文件(*.htm,*.html)中插入Java程序段(Scriptlet)和JSP标记(tag),从而形成JSP文件,后缀名为(*.jsp)。


JSP forward用法分析,需要的朋友可以参考下。
1.首页(填写姓名)(可选,表单post到time.jsp即可):

2.判断时间forward到不同页面:
time.jsp:
 
<%-- 
Document : index 
Created on : 2009-10-3, 15:48:00 
Author : lucifer 
--%> 
<%@page contentType="text/html" pageEncoding="UTF-8"%> 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd"> 
<%@page import="java.util.Date" %> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
<title>JSP Page</title> 
</head> 
<body> 
<% 
Date dat = 
new Date(); 
if(dat.getHours() <= 12){ 
%> 
<jsp:forward page="AmGreeting.jsp"/> 
<%} 
else{ 
%> 
<jsp:forward page="PmGreeting.jsp"/> 
<%} 
%> 
</body> 
</html> 

3.如果是早上:
AmGreeting.jsp:
 
<%-- 
Document : AmGreeting 
Created on : 2009-10-3, 16:00:10 
Author : lucifer 
--%> 
<%@page contentType="text/html" pageEncoding="UTF-8"%> 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
<title>JSP Page</title> 
</head> 
<body> 
<h1>Good Morning! </h1> 
<% 
String name = request.getParameter("userName"); 
out.println(name); 
%> 
!!! 
</body> 
</html> 

如果是下午:
PmGreeting.jsp:
 
<%-- 
Document : AmGreeting 
Created on : 2009-10-3, 16:00:10 
Author : lucifer 
--%> 
<%@page contentType="text/html" pageEncoding="UTF-8"%> 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
<title>JSP Page</title> 
</head> 
<body> 
<h1>Good Afternoon! </h1> 
<% 
String name = request.getParameter("userName"); 
out.println(name); 
%> 
!!! 
</body> 
</html> 


最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务