Servlet与Jsp之间SESSION值传递问题? resulset 可能与Statement 和Connection的状态有关,所以若rs会出错!建议把值取出来用vetor存放然后传递 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 有的application server要求session里面的对象能序列化,ResultSet不能序列化 Servlet与Jsp之间SESSION值该怎么传递哪? 谢谢,我换了别的都一样,我想问题还是出在SESSION值没有取到!关注Servlet与Jsp之间SESSION值该怎么传递? session保存的应该是字符串,而不是一个不能序列化的对象。你这种做法是不对的,你应该考虑别的做法。 不会吧?HttpSession 的putValue方法可是这样定义的:putValue(String,Object) 但这个Object应该是序列化的对象 session保存的对象应该能够序列化,另外你可以1.在servlet中session保存一个字符串,然后在jsp中看能不能得到,如果能得到的话,说明用session保存ResultSet是不行的;2.你的rs.getString("name")中rs用在while(rs.next()){}中了吗? 谁只要能告诉我Servlet与Jsp之间SESSION值该怎么传递的我就给分了!即如何在Servlet中设置一SESSION值,怎么POST到*.Jsp,在*.Jsp中取之,用之。 To scarab()我在servlet中session保存一个字符串,然后在jsp中也不能得到。我想可能是SESSION值没有POST到*.Jsp。 Servlet的session和JSP你的session是同一对象 //Properties.javaimport java.io.*;import javax.servlet.http.*;import javax.servlet.*;import testdir.mysql;//import mysql.java;import java.sql.*;import java.util.*;public class Properties extends HttpServlet{ public void doGet(HttpServletRequest req,HttpServletResponse resp throws rvletException,IOException { resp.setContentType("text/html"); PrintWriter out = resp.getWriter(); out.println("<html>"); out.println("<body>"); out.println("<head>"); out.println("<title>hello</title>"); out.println("<body>"); out.println("</html>"); HttpSession Session = req.getSession(true Session.putValue("test","lvjianshan"); resp.sendRedirect("http://lvjianshan/testdir/jsp/wuqingyi/test.jsp"); }// test.jsp<html><title>lvjianshan</title><% String temp = new String(); temp = (String)session.getValue("test"); out.println("the session is:"); out.println(temp);%></html> 有一段拷错了,应该是:HttpSession Session = req.getSession(true);Session.putValue("test","lvjianshan");resp.sendRedirect("http://lvjianshan/testdir/jsp/wuqingyi/test.jsp"); session 在Servlet与Jsp之间可以互传的 谢谢:(再加分)wangtaoyy(嘉陵江) scarab(没有尾巴的鲨鱼):是我错了,我将自己建了一个对象,将他作为SESSION值,也可以在JSP中显示其属性。看来ResultSet不能序列化的,那有没有更好的办法哪?只能照xmvigour(微电)说的吗? 网页即时更新问题,求解答 请问jni能做到web服务器端的jsp页面调用本地c++程序中的函数吗? 关于网站用户缓存设计问题(呼唤牛牛) 关于复选框的问题 session值在新窗口中变成NULL 紧急求助!tomcat 5.0.19下面运行一段程序出错! 求高手指教如何开发在线小游戏网站 为什么就是编译不过去呢?? 如何用IP地址去访问这个Web Application? JSP网页特效? 初学JSP的苦恼: JSP页面之间如何进行对象序列化传递???请教代码写法.I am online now。
关注Servlet与Jsp之间SESSION值该怎么传递?
HttpSession 的putValue方法可是这样定义的:
putValue(String,Object)
即如何在Servlet中设置一SESSION值,怎么POST到*.Jsp,在*.Jsp中取之,用之。
我在servlet中session保存一个字符串,然后在jsp中也不能得到。我想可能是SESSION值没有
POST到*.Jsp。
import java.io.*;
import javax.servlet.http.*;
import javax.servlet.*;
import testdir.mysql;
//import mysql.java;
import java.sql.*;
import java.util.*;
public class Properties extends HttpServlet
{
public void doGet(HttpServletRequest req,HttpServletResponse resp
throws rvletException,IOException
{
resp.setContentType("text/html");
PrintWriter out = resp.getWriter();
out.println("<html>");
out.println("<body>");
out.println("<head>");
out.println("<title>hello</title>");
out.println("<body>");
out.println("</html>");
HttpSession Session = req.getSession(true Session.putValue("test","lvjianshan");
resp.sendRedirect("http://lvjianshan/testdir/jsp/wuqingyi/test.jsp");
}
// test.jsp
<html>
<title>lvjianshan</title>
<%
String temp = new String();
temp = (String)session.getValue("test");
out.println("the session is:");
out.println(temp);
%>
</html>
HttpSession Session = req.getSession(true);
Session.putValue("test","lvjianshan");
resp.sendRedirect("http://lvjianshan/testdir/jsp/wuqingyi/test.jsp");
wangtaoyy(嘉陵江)
scarab(没有尾巴的鲨鱼):
是我错了,我将自己建了一个对象,将他作为SESSION值,也可以在JSP中显示其属性。
看来ResultSet不能序列化的,那有没有更好的办法哪?
只能照xmvigour(微电)说的吗?