您的位置:首页 > Web前端 > JavaScript

第一个jsp程序

2011-03-11 02:07 162 查看
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

<%

String path = request.getContextPath();

String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%>

<%

Locale locale = request.getLocale();//得到用户本地批信息

Calendar calendar = Calendar.getInstance(locale);//得到用记的所在地的时间

int hour = calendar.get(Calendar.HOUR_OF_DAY);//得到小时

String greeting = "";

if(hour <=6){

greeting="凌晨好 小陌,你应该睡觉了,良好的睡眠是美好一天的开始";

}else if(hour <=9){

greeting ="早上好,早餐应该注意营养";

}else if(hour <=12){

greeting="上午好,工作时注意保护眼睛";

}else if(hour <=18){

greeting="下午好,小心工作中打瞌睡";

}else if(hour <=24){

greeting="晚上好,放松一下自己吧,好好休息,睡觉不要太晚啊@!#";

}

%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>

<base href="<%=basePath%>">

<title>欢迎界面</title>

<meta http-equiv="pragma" content="no-cache">

<meta http-equiv="cache-control" content="no-cache">

<meta http-equiv="expires" content="0">

<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">

<meta http-equiv="description" content="This is my page">

<!--

<link rel="stylesheet" type="text/css" href="styles.css">

-->

</head>

<body>

<table>

<tr>

<td><%=greeting %></td>

</tr>

</table>

</body>

</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: