主题:求救续 郁闷的作业 大师级帮个忙 感激不尽
JSP作业参考
date.jsp
<html>
<head>
</head>
<body>
<%@page language="java" contentType="text/html;charset=gb2312"%>
我的第一个JSP程序
<br><br>
今天是 <%java.util.Date date=new java.util.Date();
out.println(date.getYear()+"年"+(date.getMonth()+1)+"月"+date.getDate()+"日"+"星期"+date.getDay());%>
<script language=javascript>
alert("<%if(date.getDay()==5)out.print("今天是周末!"); else out.print("今天不是周末!");%>");
</script>
</body>
</html>
1.参考程序date.jsp
请修改为:如果今天是10日,就弹出对话框"今天你有约会!",否则就弹出对话框"今天你没有约会!"
request.jsp
<%@page contentType="text/html;charset=gb2312"%>
<html>
<body>
<form method="post" action="response.jsp">
<p>用户:<input type="text" name="name"></p>
<p>密码:<input type="password" name="password"></p>
<p><input type="submit" name="submit" value="确定"></p>
</form>
</body>
<html>
response.jsp
<%@page contentType="text/html;charset=gb2312"%>
<html>
<body>
<form method="post" action="response.jsp">
<p>用户:<input type="text" name="name"></p>
<p>密码:<input type="password" name="password"></p>
<p><input type="submit" name="submit" value="确定"></p>
</form>
</body>
<html>
2.参考程序request.jsp和response.jsp
请修改为:如果用户名是wp07205015,密码是404040就显示"密码正确",否则显示"用户名或密码错误"
toupiao.html
<html>
<head><title>在线投票</title></head>
<body bgcolor="#FFFFFF">
<table width="300" border="1" cellspacing="0" cellpadding="0" >
<tr><td>投票题目:你认为JSP容易学么?<td></tr>
<form name="toupiao" method="post" action="result.jsp" >
<tr>
<td><input type="radio" name="toup" value="easy" checked>容易<br>
<input type="radio" name="toup" value="general">一般<br>
<input type="radio" name="toup" value="hard">较难<br>
<input type="submit" name="submit" value="提交" >
</td>
</tr>
</form>
</table>
</body>
</html>
result.jsp
<%@ page import="java.util.* " %>
<%@ page import="java.lang.* " %>
<%@ page import=" java.io.*" %>
<%!long b1,b2,b3;%>
<% String toup=request.getParameter("toup");
String mydata="";
//String FileName="D:"+System.getProperty("file.separator")+"toupiao.txt";
String FileName="toupiao.txt";
FileWriter resultsFile=new FileWriter(FileName,true);
File myfile=new File(FileName);
if(!(myfile.exists())){
PrintWriter toFile=new PrintWriter(resultsFile);
toFile.println("0:0:0");}
FileInputStream tfile=new FileInputStream(FileName);
String str="";
int c;
while((c=tfile.read())!=-1)
str=str+(char)c;
int first=str.indexOf(":");
int last=str.lastIndexOf(":");
int lenth=str.length();
String First=str.substring(0,first);
String Next=str.substring(first+1,last);
String Last=str.substring(last+1,lenth);
tfile.close();
Long a1=new Long(First);
Long a2=new Long(Next);
Long a3=new Long(Last);
b1=a1.longValue();
b2=a2.longValue();
b3=a3.longValue();
if(toup.compareTo("easy")==0) b1=b1+1;
if(toup.compareTo("general")==0) b2=b2+1;
if(toup.compareTo("hard")==0) b3=b3+1;
str=b1+":"+b2+":"+b3;
RandomAccessFile savefile=new RandomAccessFile(FileName,"rw");
savefile.writeBytes(str);
savefile.close();
%>
投票结果:<br>
容易:<img src=dot.gif height=13 width=<%=3*b1%>><%=b1%><br>
一般:<img src=dot.gif height=13 width=<%=3*b2%>><%=b2%><br>
较难:<img src=dot.gif height=13 width=<%=3*b3%>><%=b3%><br>
合计:<%=b1+b2+b3%><br>
<a href="toupiao.html">返回</a>
3.参考程序toupiao.html和result.jsp
在result.jsp里加代码:如果投容易的票数超过40就显示"哇,这么多人会JSP!",否则显示"怎么很少人会JSP啊!"
date.jsp
<html>
<head>
</head>
<body>
<%@page language="java" contentType="text/html;charset=gb2312"%>
我的第一个JSP程序
<br><br>
今天是 <%java.util.Date date=new java.util.Date();
out.println(date.getYear()+"年"+(date.getMonth()+1)+"月"+date.getDate()+"日"+"星期"+date.getDay());%>
<script language=javascript>
alert("<%if(date.getDay()==5)out.print("今天是周末!"); else out.print("今天不是周末!");%>");
</script>
</body>
</html>
1.参考程序date.jsp
请修改为:如果今天是10日,就弹出对话框"今天你有约会!",否则就弹出对话框"今天你没有约会!"
request.jsp
<%@page contentType="text/html;charset=gb2312"%>
<html>
<body>
<form method="post" action="response.jsp">
<p>用户:<input type="text" name="name"></p>
<p>密码:<input type="password" name="password"></p>
<p><input type="submit" name="submit" value="确定"></p>
</form>
</body>
<html>
response.jsp
<%@page contentType="text/html;charset=gb2312"%>
<html>
<body>
<form method="post" action="response.jsp">
<p>用户:<input type="text" name="name"></p>
<p>密码:<input type="password" name="password"></p>
<p><input type="submit" name="submit" value="确定"></p>
</form>
</body>
<html>
2.参考程序request.jsp和response.jsp
请修改为:如果用户名是wp07205015,密码是404040就显示"密码正确",否则显示"用户名或密码错误"
toupiao.html
<html>
<head><title>在线投票</title></head>
<body bgcolor="#FFFFFF">
<table width="300" border="1" cellspacing="0" cellpadding="0" >
<tr><td>投票题目:你认为JSP容易学么?<td></tr>
<form name="toupiao" method="post" action="result.jsp" >
<tr>
<td><input type="radio" name="toup" value="easy" checked>容易<br>
<input type="radio" name="toup" value="general">一般<br>
<input type="radio" name="toup" value="hard">较难<br>
<input type="submit" name="submit" value="提交" >
</td>
</tr>
</form>
</table>
</body>
</html>
result.jsp
<%@ page import="java.util.* " %>
<%@ page import="java.lang.* " %>
<%@ page import=" java.io.*" %>
<%!long b1,b2,b3;%>
<% String toup=request.getParameter("toup");
String mydata="";
//String FileName="D:"+System.getProperty("file.separator")+"toupiao.txt";
String FileName="toupiao.txt";
FileWriter resultsFile=new FileWriter(FileName,true);
File myfile=new File(FileName);
if(!(myfile.exists())){
PrintWriter toFile=new PrintWriter(resultsFile);
toFile.println("0:0:0");}
FileInputStream tfile=new FileInputStream(FileName);
String str="";
int c;
while((c=tfile.read())!=-1)
str=str+(char)c;
int first=str.indexOf(":");
int last=str.lastIndexOf(":");
int lenth=str.length();
String First=str.substring(0,first);
String Next=str.substring(first+1,last);
String Last=str.substring(last+1,lenth);
tfile.close();
Long a1=new Long(First);
Long a2=new Long(Next);
Long a3=new Long(Last);
b1=a1.longValue();
b2=a2.longValue();
b3=a3.longValue();
if(toup.compareTo("easy")==0) b1=b1+1;
if(toup.compareTo("general")==0) b2=b2+1;
if(toup.compareTo("hard")==0) b3=b3+1;
str=b1+":"+b2+":"+b3;
RandomAccessFile savefile=new RandomAccessFile(FileName,"rw");
savefile.writeBytes(str);
savefile.close();
%>
投票结果:<br>
容易:<img src=dot.gif height=13 width=<%=3*b1%>><%=b1%><br>
一般:<img src=dot.gif height=13 width=<%=3*b2%>><%=b2%><br>
较难:<img src=dot.gif height=13 width=<%=3*b3%>><%=b3%><br>
合计:<%=b1+b2+b3%><br>
<a href="toupiao.html">返回</a>
3.参考程序toupiao.html和result.jsp
在result.jsp里加代码:如果投容易的票数超过40就显示"哇,这么多人会JSP!",否则显示"怎么很少人会JSP啊!"