javax.servlet.http:
[color=red]Interface HttpServletRequest[/color]
this interface extends the interface ServletRequest to provide request interformation for the http HTTP servlets.
The servlet container creates an HttpServletRequest object and passes it as an argument to the servlet's service methods (doGet, doPost, etc).
[color=blue]Method:[/color]
getContextPath(): obtain the project's name '/example'
getCookies():return an array containing all of the Cookie objects the client send with this request
getHeader():
getMethod()
getPathInfo()
getRequestSessionId()可能跟session的id不同,如果客户没有指定一个会话ID,此方法返回null。
getRequestURI() 获得项目的http 请求的uri
getRequestURL()获得url
ps: url和uri的区别 url是通过浏览器访问的地址名称,uri是项目路径没有http和网络地址相关信息
getSession() 获得当前session
getSession(boolean create) 如果create=true 则建立一个新的session,create=false则返回null或者获得当前session
Servlet 3.0中增加的 authenticate().login(),logout()这三个方法实在不知道怎么用啊。。第一次觉得网上的资料好少。
[color=red]Interface HttpServletResponse[/color]
addCookie(Cookie cookie)
addHeader(String name,String value)
setRedirect(String loaction)
encodeURL(String url) return String:重写url 在cookie被当前大多数浏览器禁用的时候,可以选择重写url这方式来报错session的跟踪。
[color=red]Interface HttpSession:
[/color]
Method:
getAttribute()
setAttribute()
getCreationTime()
getId()
getMaxInactiveInterval()
setMaxInactiveInterval()
getServletContext()
invalidate():是当前的session失效,如果调用这个方法后 在执行有关session的操作
如session.getAttribute就是报500的错
isNew()
removeAttribute()
[color=red]
Interface HttpSessionAttributeListener:[/color]
对session中的属性情况进行了监听
method:
attributeAdded(HttpSessionAttributeEvent)
attributeRemoved(HttpSessionAttributeEvent)
attributeReplaced(HttpSessionAttributeEvent)
[color=red]Interface HttpSessionListener[/color]
对session的初始化和销毁情况进行了监控
method:
sessionCreated(HttpSessionEvent)
sessionDestroyed(HttpSessionEvent)
[color=red]Interface HttpSessionBindingListener[/color]
对绑定到session属性的对象进行了监听
valueBound(HttpSessionBindingEvent)
valueUnbound(HttpSessionBindingEvent)
[color=red]HttpSessionActivationListener[/color]
是对不同VM之间session的交互的监听
method:
sessionDidActivate(HttpSessionEvent)
sessionWillPassivate(HttpSessionEvent)
常用类:
Cookie
HttpServlet
<-----------------------以前没用过的------------->
HttpServletRequestWrapper
HttpServletResponseWrapper
[color=red]Interface HttpServletRequest[/color]
this interface extends the interface ServletRequest to provide request interformation for the http HTTP servlets.
The servlet container creates an HttpServletRequest object and passes it as an argument to the servlet's service methods (doGet, doPost, etc).
[color=blue]Method:[/color]
getContextPath(): obtain the project's name '/example'
getCookies():return an array containing all of the Cookie objects the client send with this request
getHeader():
getMethod()
getPathInfo()
getRequestSessionId()可能跟session的id不同,如果客户没有指定一个会话ID,此方法返回null。
getRequestURI() 获得项目的http 请求的uri
getRequestURL()获得url
ps: url和uri的区别 url是通过浏览器访问的地址名称,uri是项目路径没有http和网络地址相关信息
getSession() 获得当前session
getSession(boolean create) 如果create=true 则建立一个新的session,create=false则返回null或者获得当前session
Servlet 3.0中增加的 authenticate().login(),logout()这三个方法实在不知道怎么用啊。。第一次觉得网上的资料好少。
[color=red]Interface HttpServletResponse[/color]
addCookie(Cookie cookie)
addHeader(String name,String value)
setRedirect(String loaction)
encodeURL(String url) return String:重写url 在cookie被当前大多数浏览器禁用的时候,可以选择重写url这方式来报错session的跟踪。
[color=red]Interface HttpSession:
[/color]
Method:
getAttribute()
setAttribute()
getCreationTime()
getId()
getMaxInactiveInterval()
setMaxInactiveInterval()
getServletContext()
invalidate():是当前的session失效,如果调用这个方法后 在执行有关session的操作
如session.getAttribute就是报500的错
isNew()
removeAttribute()
[color=red]
Interface HttpSessionAttributeListener:[/color]
对session中的属性情况进行了监听
method:
attributeAdded(HttpSessionAttributeEvent)
attributeRemoved(HttpSessionAttributeEvent)
attributeReplaced(HttpSessionAttributeEvent)
[color=red]Interface HttpSessionListener[/color]
对session的初始化和销毁情况进行了监控
method:
sessionCreated(HttpSessionEvent)
sessionDestroyed(HttpSessionEvent)
[color=red]Interface HttpSessionBindingListener[/color]
对绑定到session属性的对象进行了监听
valueBound(HttpSessionBindingEvent)
valueUnbound(HttpSessionBindingEvent)
[color=red]HttpSessionActivationListener[/color]
是对不同VM之间session的交互的监听
method:
sessionDidActivate(HttpSessionEvent)
sessionWillPassivate(HttpSessionEvent)
常用类:
Cookie
HttpServlet
<-----------------------以前没用过的------------->
HttpServletRequestWrapper
HttpServletResponseWrapper