Servlet自己获取jsp的九大对象吗。jsp九大内置对象是容器自定义的,自创建的
out 相当于
PrintWrite write=respons.getWrite();
write.println(“some test and html”);
Request 就是Servlet的request
reponse 就是Servlet的reponse
session 通过request.getsession()来获得
application 就是ServletContext
config 就是ServletConfig
上边2个的取得方法和session一样就不说了
下边3个属性是Servlet里没有的(也不能说没有 但是不能调用)
exception
PageContext
Page
//获得out对象
import java.io.PrintWritter;
...
public void doGet(HttpServletRequest request,HttpServletResponse response)thows ServletException,IOException{
response.setContentType("text/html;charset=gb2312");
PrintWriter out=response.getWriter();
}
//获得request和response对象
public void doGet(HttpServletRequest request,HttpServletResponse response)thows ServletException,IOException{
//将request参数当成request对象使用
//将response参数当成response对象使用
}
//获得session对象
import javax.servlet.http.HttpSession;
...
public void doGet(HttpServletRequest request,HttpServletResponse response)thows ServletException,IOException{
Httpsession session=request.getSession();
//将session当成session对象使用
}
import java.io.PrintWritter;
...
public void doGet(HttpServletRequest request,HttpServletResponse response)thows ServletException,IOException{
response.setContentType("text/html;charset=gb2312");
PrintWriter out=response.getWriter();
}
//获得request和response对象
public void doGet(HttpServletRequest request,HttpServletResponse response)thows ServletException,IOException{
//将request参数当成request对象使用
//将response参数当成response对象使用
}
//获得session对象
import javax.servlet.http.HttpSession;
...
public void doGet(HttpServletRequest request,HttpServletResponse response)thows ServletException,IOException{
Httpsession session=request.getSession();
//将session当成session对象使用
}
孜孜不倦,必能求索;风尘仆仆,终有归途。