1. homepage (enter a name) (optional, form post to time. jsp ):
Omitted
2. determine the time forward to different pages:
Time. jsp:
Copy codeThe Code is as follows:
<% --
Document: index
Created on:, 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. If it is morning:
AmGreeting. jsp:
Copy codeThe Code is as follows:
<% --
Document: AmGreeting
Created on:, 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>
If it is afternoon:
PmGreeting. jsp:
Copy codeThe Code is as follows:
<% --
Document: AmGreeting
Created on:, 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>