request.setAttribute("abc",v);response.sendRedirect("http://cg:7001/clubsite/index.jsp");
不能这样传参数,传不过去。

解决方案 »

  1.   

    对,试试这个。
             RequestDispatcher dispatcher = null;
             request.setAttribute("abc",v);
    dispatcher = request.getRequestDispatcher("index.jsp");
    dispatcher.forward(request, response);
      

  2.   

    test.servlet源程序:
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;public class test extends HttpServlet {
    protected ServletConfig servletConfig;
      public void init(ServletConfig config) {
        this.servletConfig = config;
      }public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException {
    response.setContentType("text/html");
    Vector v=new Vector();
    v.add("aa");
    v.add("bb");
    request.setAttribute("abc",v);
    servletConfig.getServletContext().getRequestDispatcher("http://cg:7001/clubsite/index.jsp").forward(request,response);
    }
    }
      

  3.   

    sendRedirect方法是服务器端返回一个代码告诉浏览器将地址重新定向到另外一个页面,当然没有办法通过setAttribute来传递参数。另外Netscape是不支持java中的sendRedirect方法的
      

  4.   

    你的request.setAttribute("abc",v)和Vector a=(Vector)request.getAttribute("abc")的request不是同一个
      

  5.   

    我要100分给你解决方案,
     把你的response.sendRedirect("http://cg:7001/clubsite/index.jsp");改为:this.getServletConfig().getServletContext().getRequestDispatcher("/index.jsp").forward(request,response)等你结果
      

  6.   

    在jsp或servlet把向量存放到session中或context中,然后在需要的地方取出来就可以了。
      

  7.   


    用了zhangbin_zhang(cat) 的程序
    页面返回:
    Error 500--Internal Server Error 
    From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:
    10.5.1 500 Internal Server Error
    The server encountered an unexpected condition which prevented it from fulfilling the request.
     
      

  8.   

    我和他的方法不一样的
    ---------------
    我要100分给你解决方案,
     把你的response.sendRedirect("http://cg:7001/clubsite/index.jsp");改为:this.getServletConfig().getServletContext().getRequestDispatcher("/index.jsp").forward(request,response)
      

  9.   

    刚实验,决对没错
    ---------
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;public class test extends HttpServlet {public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException {
    Vector v=new Vector();
    v.add("aa");
    v.add("bb");
    request.setAttribute("abc",v);
    this.getServletConfig().getServletContext().getRequestDispatcher("/test.jsp").forward(request,response);
    //response.sendRedirect("/sohosystem/test.jsp");
    }
    }
    ---------------
    <%@ page contentType="text/html;charset=gb2312"%> 
    <%@ page import="java.util.*"
    %> 
    <%Vector a=(Vector)request.getAttribute("abc");
    if(request.getAttribute("abc")!=null){
    out.println("OK");
    }
    if(a==null){
    out.println("<p>a is null");
    }
    %>
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    </head><body>
    </body>
    </html>
      

  10.   

    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;public class test extends HttpServlet {public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException {
    response.setContentType("text/html");
    Vector v=new Vector();
    v.add("aa");
    v.add("bb");
    request.setAttribute("abc",v);
      this.getServletConfig().getServletContext().getRequestDispatcher("http://localhost:7001/clubsite/clubsite/publish.jsp").forward(request,response);
      } }