`
chenghuixy
  • 浏览: 20622 次
  • 性别: Icon_minigender_1
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

servlet中的setAttribute

阅读更多

今天打算帮同学把他的毕业设计的BBS做了,我只想做的简单。就用jsp+servlet

结果在用servlet转向的时候用response我在servlet中用setAttribute保存的参数在jsp页面里面就是获取不到。到后来才知道不能用response,转向的时候用  getServletContext().getRequestDispatche(your jsp).forward(
    request, response);原因我理解就是getAttribute只作用在服务器重定向中。

分享到:
评论

相关推荐

    servlet2.4doc

    Called by the servlet container to indicate to a servlet that the servlet is being taken out of service. destroy() - Method in class javax.servlet.GenericServlet Called by the servlet container to ...

    request.setAttribute 语句前总显示红色感叹号解决办法 HTTP Status 500 -

    The method setAttribute(String, Object) in the type ServletRequest is not applicable for the arguments (String, double) y2ssh.sg.chp1.action.AddAction.execute(AddAction.java:18) y2ssh.sg.chp1....

    猜数题,JSP,全是JSP页面,没有SERVLET和BEAN

    session.setAttribute("count", new Integer(0)); session.setAttribute("save", new Integer(num)); session.setAttribute("max",new Integer(100)); session.setAttribute("min",new ...

    实验6 Servlet 二1

    多个Servlet对象共享数据新建两个不同的Servlet,在一个Servlet中通过ServletContext.setAttribute()设置一个全局属性

    Servlet解耦

    public class NoloCAction ... session.setAttribute("bookName", this.bookName); session.setAttribute("bookPrice", this.bookPrice); session.setAttribute("bookPress", this.bookPress); return SUCCESS; } }

    Servlet查询数据库案例--Query(java源码)

    request.setAttribute(Counter.ATTRIBUTE_NAME,Query.class.getName()); // Tell the dispatcher to invoke its servlet and include the output dispatcher.include(request, response); } // Finally, ...

    .jsp和servlet验证码

    request.getSession(true).setAttribute("codes", vcode); for (int i = 0; i ; i++) { g2.setFont(new Font("Times New Roman", Font.HANGING_BASELINE, FontSize)); double rot = getRandomJiao(); // 旋转...

    基于servlet的购物车

    request.getSession().setAttribute("shoppingCart", SC); // System.out.println("SESSION===================>"+request.getSession().getAttribute("shoppingCart")); request.getRequestDispatcher(...

    servlet小型项目

    servlet小项目 public class BookListener implements ServletContextListener { public void contextDestroyed(ServletContextEvent arg0) { // TODO Auto-generated method stub } public void context...

    可以查看上线人数 监听器 servlet Ajax聊天系统

    可以查看上线人数 监听器 servlet 登出时,session失效。 UserInfoList list=UserInfoList.getInstance();//实例一个用户对象 UserInfoTrace ut=new UserInfoTrace();//实例一个ut String name=(String)session....

    jsp servlet

    //重定向的跳转方式为get(如果下一个servlet中没有get方法 将出现异常) 注意事项:a标签和重定向差不多 通过a标签进行跳转时也是调用doGet()方法 //从地址栏上方进入网页也是调用的servlet的get方法 //在使用doGet...

    javax.servlet.jsp-api-2.3.2-b01.jar.zip

    用于网络开发的api,版本是2.3.2,解决jsp代码中不能使用pageContext.setAttribute方法的api

    投票系统,基于mvc开发,jsp+servlet+mysql

    import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet....

    基于JSP+JavaBean+Servlet三层架构员工考勤管理系统源码+数据库+项目说明.zip

    7) 操作完数据库,如果是查询数据 将结果集返回到servlet页面,通过setAttribute(key,value)将数据存入request作用域,跳转回JSP页面,再通过JSP页面的EL表达式获取存入的数据。 8) 如果是修改数据,修改完成后...

    简单的servlet增,删,改,查

    request.setAttribute("listUsers", list); // response.sendRedirect("/sshmvc/listUser.jsp"); request.getRequestDispatcher("/listUser.jsp") .forward(request, response); } } import="java....

    Filter_Listener相信代码使用

    import java.io.IOException;... request.setAttribute("message", "你进行了不合法的操作!!!"); request.getRequestDispatcher("error.jsp").forward(request, response); 里面有更详细的代码。。。

    JSP100选择题 JSP100选择题 适合考前练习

    2 给定一个 Servlet 的doGet方法中的代码片段,如下: request.setAttribute(“name”,”zhang”); response.sendRedirect(“http://localhost:8080/servlet/MyServlt”); 那么在 MyServlet 中可以使用()方法把...

    SpringMvc初步入门简单的例子

    import org.springframework.web.servlet.mvc.Controller; import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse...

    javaweb的servlet的forward协作

    本项目的主要是模仿服务员、初始、送菜人展开的 使用forward定向转发数值 其中比较关键的是request.getParameter()和request.setAttribute 前者是接受,后者是传值

    数据库测试test.sql

    再存放到application作用域中 context.setAttribute("count",count2); //http://192.168.58.250:8080/myservlet2/servlet/admin/success.jsp response.sendRedirect("../admin/success.jsp"); }else{ //失败...

Global site tag (gtag.js) - Google Analytics