`
mmdev
  • 浏览: 12943772 次
  • 性别: Icon_minigender_1
  • 来自: 大连
文章分类
社区版块
存档分类
最新评论

jsp内置对象的使用(三)

 
阅读更多

最后,在index.jsp的代码中,用session对象来获取用户的信息,主要用到了session.getAttribute()方法,来获取用户的信息。最终,index.jsp的代码为:

<%@pagelanguage="java"contentType="text/html;charset=UTF-8"

pageEncoding="UTF-8"%>

<!DOCTYPEhtmlPUBLIC"-//W3C//DTDHTML4.01Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<metahttp-equiv="Content-Type"content="text/html;charset=UTF-8">

<title>Inserttitlehere</title>

<styletype="text/css">

div{

margin:0auto;

width:700px;

}

body{

font-size:15px;

font-color:#ffbbcc;

font-height:160%;

}

</style>

</head>

<body>

<div>

<%Stringuser=(String)session.getAttribute("user");%>

<%=user%>,欢迎您!

性别:<%Stringsex=(String)session.getAttribute("sex");%>

<%=sex%>

您出生于:<%Stringyear=(String)session.getAttribute("year");%>

<%Stringmonth=(String)session.getAttribute("month");%>

<%=year%>年<%=month%>月</div>

</body>

</html>

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics