标签:pass 字符 name bytes tle login tostring for []
<%@ page language="java" contentType="text/html; charset=utf-8"
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>中转站</title>
<%!
public String codeToString(String str)
{//处理中文字符串的函数
String s=str;
try
{
byte tempB[]=s.getBytes("ISO-8859-1");
s=new String(tempB,"utf-8");
return s;
}
catch(Exception e)
{
return s;
}
}
%>
</head>
<body>
<%
String username=request.getParameter("username");
String userpassword=request.getParameter("userpassword");
if(username!=null&userpassword!=null)
{//如果用户名和密码都合法,记下用户名,一般把用户和密码存在数据库中,
//用数据库中的信息与提交的用户名和密码比较以进行用户合法性检查,
//这些内容在后续章节中会继续学习
session.setAttribute("username",codeToString(username));
}
%>
<jsp:forward page="LoginInfor.jsp"></jsp:forward>
</body>
</html>
Java web实验 station.jsp session属性设置和获取
标签:pass 字符 name bytes tle login tostring for []
原文地址:http://www.cnblogs.com/meng2/p/7679222.html