📄 index.jsp
字号:
<%@ page contentType="text/html;charSet=gb2312"%>
<%
response.setHeader("Cache-Control","no-store");
response.setDateHeader("Expires",0);
%>
<%
String s = null;
String[] question = new String[4];
s = request.getRealPath("question.txt");
String strTemp = null;
int i;
java.io.RandomAccessFile rf = null;
try
{
rf = new java.io.RandomAccessFile(s,"r");
}
catch(Exception e)
{
System.out.println(e);
}
for(i=0;i<4;i++)
{
try
{
strTemp = rf.readLine();
}
catch(Exception e) {
strTemp = "None Question";
}
if(strTemp==null)strTemp = "None Question";
question[i] = strTemp;
}
%>
<html>
<head>
<title></title>
</head>
<p>
<body>
<table width="180" border="1" bordercolor="#999999">
<tr>
<td align=center>投票调查</td>
</tr>
<form name=frm method=post action=write.jsp>
<tr>
<td>
<%
String ss = null;
for (i=0;i<4;i++)
{
ss = "<input type='radio' name='choice' value=" + i+">"+(char)('A'+i)+","+ question[i]+"<br>";
out.println(ss);
}
%>
</td>
</tr>
<tr>
<td align=center><input type=submit value="我 投 一 票"></td>
</tr>
<%
String sCount = null;
int sum = 0;
sCount = request.getRealPath("count.txt");
int[] mCount = new int[4];
java.io.RandomAccessFile rf1 = null;
try {
rf1 = new java.io.RandomAccessFile(sCount,"r");
} catch(Exception e)
{
System.out.println(e);
}
for(i=0;i<4;i++)
{
strTemp = null;
try {
strTemp = rf1.readLine();
} catch(Exception e)
{
strTemp = "0";
}
if(strTemp==null) strTemp = "0";
strTemp.trim();
try
{
mCount[i] = Integer.parseInt(strTemp);
sum += mCount[i];
}
catch(NumberFormatException e)
{
out.println(e);
}
}
%>
<%
for(i=0;i<4;i++)
{
%>
<tr><td><IMG SRC="a0.bmp" HEIGHT=10 WIDTH=<%if (sum!=0) out.println(mCount[i]*250/sum);%>><%=mCount[i]%></td></tr>
<%
}
%>
</form>
</table>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -