session.setAttribute("userName","session");
解决方案 »
- <a>转跳WEB-INF中的jsp的问题
- html5或js中实现一个鼠标响应事件的问题
- 可以从Interceptor里往action传值吗?怎么传?
- struts2中,cookie保存操作,在哪操作比较好呢?
- 高分求助页面转换的显示问题!!!!
- 如何在jsp页面中打开流文件啊???请高手指点指点啊!!!
- linux kill tomcat线程 网卡掉了
- jacob 问题分享
- servlet 因该放到哪个目录??(Resin平台)
- 为什么hql语句当查询条件为中文时查不出结果,英文就可以
- 为什么我的机子装J2SDK1.4.1在编译.java文件时老出错!!(在线等)
- 怎样只去掉一段字符串末尾的空格?
请指点迷津
session.setAttribute("userName","session");
谢谢zxhong(红);
请指点迷津
<%=(String)session.getAttribute("userName");%>
另外不要单独开一个窗口来测试session这样session.会失效的
在saveSession.jsp定义两个连接对象
一个是使用response.encodeURL方法进行编码
一个是一般的连接
使用第一种方法可以显示出中的值
而的二种不行
String ls_encode_url = response.encodeURL("showSession.jsp");
String ls_normal_url = "showSession.jsp";
<a href="<%= ls_encode_url %>"> 使用地址转换</a><BR><BR>
<a href= "<%= ls_normal_url %>"> 一般连接</a>
<%@ page contentType="text/html; charset=GB2312" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.lang.*" %>
<%@ page import="java.util.*" %>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<%
session.setAttribute("userName","session");
out.println("userName: " + (String)session.getAttribute("userName"));
%>
<body>
<form name="form1" method="post">
<p><a href="two.jsp">click</a></p>
</form>
</body>
</html><!-- two.jsp -->
<%@ page contentType="text/html; charset=GB2312" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.lang.*" %>
<%@ page import="java.util.*" %>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<p><font size="+4"><%= (String)session.getAttribute("userName")%></font></p>
</body>
</html>