CSDN博客

img andunkafei

session变量的操作

发表于2004/9/21 14:43:00  920人阅读

分类: 【Jsp】

将变量放入session中去 例:session.putValue("anchor",v_key);

<%@ page contentType="text/html;charset=gb2312" %>
<%@ page contentType="text/html;charset=gb2312" %>
<%@ page info="database handler"%>
<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.sql.*"%>
<%
 	request.setCharacterEncoding("gb2312");
 		
 	String v_file_name = request.getParameter("filename");
 	String v_key = request.getParameter("key");
	
 	//将变量v_file_name,v_key放入session中去
 	session.putValue("bodyFile",v_file_name);
 	session.putValue("anchor",v_key);
 
 	if(v_file_name!=null && v_key!=null) { 
 		response.sendRedirect(request.getContextPath() +"/jsp/help.jsp#"+v_key);
	}	
%> 

取出session变量 例:session.getValue("anchor");

<%@ page language="java" %>
<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/tld/struts-tiles.tld" prefix="tiles" %>
<%@ page contentType="text/html;charset=gb2312" %>
<%
	/*
		get param from session
	*/
	session.getValue("bodyFile");
	session.getValue("anchor");	
%>

<tiles:insert template="./helpFramesetLayout.jsp">
	<tiles:put name="title" content="*TGPMS使用帮助*" />
	<tiles:put name="header" content="<%="/jsp/search.jsp"%>" direct="true" />
	<tiles:put name="body" content="<%="/jsp/manual/"+session.getValue("bodyFile")+"#"+session.getValue("anchor")%>" direct="true" />	
	<tiles:put name="footer" content="<%="/jsp/footer.html"%>" direct="true" />		
</tiles:insert>
0 0

相关博文

我的热门文章

img
取 消
img