index.jsp
————————————————
<%@ page language="java" pageEncoding="GBK"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<head>
<title>测试<c:choose>等标签</title>
</head>
<body><c:choose>
<c:when test="${empty sessionScope.user}">
<center>
<form name="form1" method="post" action="deal.jsp">
用户名:
<input name="user" type="text" id="user">
<input type="submit" name="Submit" value="登录">
</form>
</center>
</c:when>
<c:otherwise>
欢迎您!${sessionScope.user} [<a href="logout.jsp">退出</a>] </c:otherwise>
</c:choose></body>
</html>
deal.jsp——————————————————————————————————<%@ page language="java" pageEncoding="GBK"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%request.setCharacterEncoding("GBK");%>
<c:set var="user" scope="session" value="${param.user}"/>
<%response.sendRedirect("index.jsp");%>logout.jsp--------------------------------------------------------
<%@ page language="java" pageEncoding="GBK"%>
<%
session.invalidate();
response.sendRedirect("index.jsp");
%>______________________
大家讨论下此程序的结果。
————————————————
<%@ page language="java" pageEncoding="GBK"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<head>
<title>测试<c:choose>等标签</title>
</head>
<body><c:choose>
<c:when test="${empty sessionScope.user}">
<center>
<form name="form1" method="post" action="deal.jsp">
用户名:
<input name="user" type="text" id="user">
<input type="submit" name="Submit" value="登录">
</form>
</center>
</c:when>
<c:otherwise>
欢迎您!${sessionScope.user} [<a href="logout.jsp">退出</a>] </c:otherwise>
</c:choose></body>
</html>
deal.jsp——————————————————————————————————<%@ page language="java" pageEncoding="GBK"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%request.setCharacterEncoding("GBK");%>
<c:set var="user" scope="session" value="${param.user}"/>
<%response.sendRedirect("index.jsp");%>logout.jsp--------------------------------------------------------
<%@ page language="java" pageEncoding="GBK"%>
<%
session.invalidate();
response.sendRedirect("index.jsp");
%>______________________
大家讨论下此程序的结果。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货