读书人

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

发布时间: 2012-03-21 13:33:14 作者: rapoo

在页面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");

读书人网 >Java Web开发

热点推荐