应该没有你考虑的问题,redirect可以通过url传递参数;forward可以用相对路径

解决方案 »

  1.   

    我说的是在servlet中如何跳转jsp,不是在jsp中
    getServletContext().getRequestDispatcher("/CerImport/11.jsp").forward(request,response);
    这个可以设置setAttribute(),但是必须用/开头
    response.sendRedirect("../CerImport/11.jsp");可以传递相对路径,但是不能request.setAttribute();
    我现在要的是两者的优点
      

  2.   

    //在Servlet的数据发送到别一个JSP中:
    .............
     request.setAttubute("messages",aaa);  //参数
     RequestDispatcher requestDispatcher=request.getRequestDispatcher("/jsp/testbean.jsp");
     requestDispatcher.forward(request,response);
    ..............
      

  3.   

    getServletContext().getRequestDispatcher("../CerImport/11.jsp").forward(request,response);有什么不可以的?
      

  4.   

    RequestDispatcher rd = req.getRequestDispatcher("error.jsp");
    rd.forward(req,res);可以的啊,并不一定要/开头的啊
      

  5.   

    单纯使用JSP的<jsp:forward>标签就可以实现,看看这个JSP的Servlet文件的源代码,你就知道怎么调用了。
      

  6.   

    看楼主这么执着用sendredirect,是为了重定向到其他服务器的资源,不能传参数是没办法的,不然用forward是不会存在这些问题的
      

  7.   

    RequestDispatcher requestDispatcher=request.getRequestDispatcher("/jsp/testbean.jsp");
     requestDispatcher.forward(request,response);这个好象有点问题!
    假如你做登陆,登陆成功转向成功页面,转是转过去了,参数也能传过去,但图片什么的就都没有了!我用的是response.sendredirect("");这个。
    虽然我不知道为什么,但后面的那个是好用的!你试试吧!
      

  8.   

    把根目录配置到web.xml中, 如果你不嫌麻烦的话
    <context-param>
     <param-name>RootDir</param-name>
     <param-value>/</param-value>
    </context-param>然后程序中
     getServletContext()
    .getRequestDispatcher(getServletContext().getInitParamter("RootDir")+"CerImport/11.jsp")
    .forward(request,response);这样行不行? 虽然有点笨
      

  9.   

    ServletContext 不是可以得到么?
    重定向你也可以把参数 Base64 处理一下直接跟在 xxx.jsp 后面, 你看人家 Sun , IBM 等下载得程序都这样, 后面跟很多参数,参数名字和参数值都很古怪,就是为了不让你看懂,