在JSP中使用SESSION出现的问题,急!

来源:百度知道 编辑:UC知道 时间:2024/05/11 12:12:55
再加入了<%@ include file = "_sessionCheck.jsp" %>后eclipse说<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>有误。不添加就能正常显示页面。为什么?
我想让每一个使用页面都先在_sessionCheck.jsp做是否登录的判断。
_sessionCheck.jsp代码如下:
<%@ page language="java" import="java.util.*,vo.*" pageEncoding="gb2312"%>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'sessionCheck.jsp' starting page</title>

<met

你是不是在两个页面中都写了这段代码:<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
建议你将"_sessionCheck.jsp中的这段代码删掉试试。

你这。。。问题都没说明白~·
服了~

eclipse有时乱报错

StuVo类没有导入,请加入如下代码到jsp
<jsp:directive.page import="包名.StuVo"/>

我个人觉得你还不够了解 Session 的用法。

<%
StuVo stu=(StuVo)session.getAttribute("user");
if(stu==null){
%>
<b>您没有登录!</b>

<%}
response.sendRedirect("login.jsp");
return;
%>
//在这段代码中,你如果 stu 取得是 null,就证明该用户没有登陆,就可以返回给用户“登陆的界面”,如果 stu 不是 null ,就证明该用户已经登陆了,就给用户“主界面”就行了,还需要做什么呢?你的session已经帮你做好,你还要多此一举的去包含个页面!!!
<%@ include file = "_sessionCheck.jsp" %>
//这句话是多出来的……