首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

在页面A使用servlet接收值,在页面B中使用,该如何解决

2012-03-21 
在页面A使用servlet接收值,在页面B中使用页面A代码form idform1 nameform1 methodpost action

在页面A使用servlet接收值,在页面B中使用
页面A代码

  <form id="form1" name="form1" method="post" action="/TestOracleFenye/servlet/TabelName">
  <input type="text" id="tableName" name="tableName"/>
  <input type="submit" name="button2" id="button2" value="确定"/>
  </form>

页面B代码:
String tableName_s=(String)request.getAttribute("t_name");

servlet代码: String t_name=request.getParameter("tableName");
System.out.println(t_name);
request.setAttribute("t_name", t_name);
request.getRequestDispatcher("/ProicedureTest.jsp").forward(request, response);


我想把页面A,INPUT中的值,在页面B上使用,用来查询表,变量t_name好像是被销毁了,当点击查询第二页这个变量就不能使用了。无效SQL


java.sql.SQLException: ORA-00903: 表名无效


[解决办法]
你应该用转发response.sendRedirect(),而不是重定向request.getRequestDispatcher("/ProicedureTest.jsp").forward(request, response);

[解决办法]
这样这是我的购物车实现代码
request.getSession().setAttribute("cart", cart);

request.getSession().getAttribute("cart");

热点排行
Bad Request.