Resquest对象
Resquest对象代表由各客户程序发往HTTP的请求报文。事实上,Request对象的功能是单向的,它只能接收客户端Web页面提交的数据,与Response对象的功能刚好相反。
Resquest接收数据时通过两个集合QueryString和Form来检索表单的数据,具体用哪一个集合,取决于Web页面提交数据的HTTP表单的Method属性,当Method属性值为“Get”时以QueryString,而Method属性值为“Post”时以Form。
//从jsp页面获取值传入数据库
String t = request.getParameter("title");
String c = request.getParameter("content");
new DB().insertnews(t, c);
//代码作用
response.sendRedirect("index.jsp");
sendRedirect作用
A-> B
B:response.sendRedirect( "index.jsp ") 能在index.jsp 中得到A页传过来的参数,
而用 <jsp:forward page= "index.jsp "/> 则不能.