Servlet

Servlet是运行在Web服务器端的java应用程序,它用java语言编写,具有java语言的优点。与普通的java程序区别是,servlet对象具有对http请求处理的功能,并且其运行需要web容器的支持。

Servlet常用API(更多方法及声明请查阅java ee API)

servlet接口

public void service(ServletRequest request,ServletResponse response)

public void destroy()

public ServletConfig getServletConfig()

public String getServletInfo()

HttpServlet类

protected void doGet(HttpServletRequest req,HttpServletResponse res)

protected void doPost(HttpServletRequest req,HttpServletResponse res)

protected void doPut(HttpServletRequest req,HttpServletResponse res)

HttpServletResquest类

public String getContextPath()

public Cookie[] getCookies()

public String getQueryString()

public String getRequestURI()

public Httpsession getsession()

HttpServletResponse类

public void addCookie(Cookie cookie)

public void sendError(int sc)

public void sendError(int sc,String msg)

public void sendRedirect(String location)

 

Servlet配置解析

创建了Servlet类后,还需要对其进行配置,目的是将其注册到Servlet容器中,以方便容器对其的调用

过滤器的创建与配置

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

posted @ 2014-05-01 16:22  blmdlm  阅读(170)  评论(0编辑  收藏  举报