📄 index.jsp
字号:
<%@page contentType="text/html;charset=gb2312"%>
<%@ page import="java.io.*"%>
<html>
<head>
<title>Welcome!</title>
</head>
<body bgcolor="#C0C0C0">
<center>
<%
int temp=1;
Integer userNum;
if(session.isNew()){
File f=new File("counter.txt");
try{
FileInputStream fin=new FileInputStream(f);
DataInputStream dataIn=new DataInputStream(fin);
temp=dataIn.readInt();
fin.close();
dataIn.close();
temp+=1;
}
catch(FileNotFoundException e){
out.println("file error!");
}
catch(IOException e){}
userNum=new Integer(temp);
application.setAttribute("userNum",userNum);
try{
FileOutputStream fout=new FileOutputStream(f);
DataOutputStream dataOut=new DataOutputStream(fout);
dataOut.writeInt(temp);
fout.close();
dataOut.close();
}
catch(FileNotFoundException e){
}
catch(IOException e){}
}
else{
userNum=(Integer)(application.getAttribute("userNum"));
if(userNum==null){out.println("error");}
temp=userNum.intValue();
}
out.println("您是第"+temp+"位访客。<br>");
%>
<%String str=session.getId();%>
<font color="#C0C0C0"><%=str%></font>
<font color="#000000">
<br>
<h1>欢迎来到我的纪念品商店</h1>
<br>
<br>
<br>
<a href="register1.jsp">用户注册</a> <a href="login1.jsp">用户登录</a>
</font>
</center>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -