`

SCWCD Notes

 
阅读更多

response.getPrintWriter() & getOutputStream() can not be called on same instance twice, otherwise throw IllegalStateException

sendRedirect() 
can not be called if response is commited/flushed, otherwise exception will be thrown
tell browser to get resource from another location

ServeletContext -> getResource() & getResourceAsStream() 
  • Can NOT access dynamic resource such as JSP, Servlet
  • Might cause security issue if not used properly

ServletContext -> getRealPath() is NOT FOR
  • file sitting in Jar file
  • file sitting in network

JSP:useBean
  1. id - compulsory
  2. scope - optional
  3. combine of following
  • class
  • type
  • class & type
  • beanName & type

<jsp:setProperty name="beanName" property="property"|param="property" />
* param is parameter from request

<jsp:setProperty/getProperty name="..." property="..." /> will do automatic conversion

JSP container populate tablib mapping in Three ways
  1. container explicit-map definition in web.xml
  2. container Implicit-map the one defined in packed Jar file (tld file contains URI info),
  3. container add known entries by default, such as http://java.sun.com/JSP/jstl/a.tld

taglib lookUp
  • roote-relative URL
  • relative URL, container will append "WEB-INF" in front of the relative URL
IF NOT FOUND
  • If absolute URI, error thrown
  • If root-relative, try to find on application's root directory
  • if relative-path, try to find it on the same location as JSP


Three different ways to get RequestDispatcher in servlet
  • getServletContext().getRequestDispatcher("/user/absolute/path/servlet")
  • ServletContext.getNamedDispatcher("nameOfServletInWebXML")
  • request.getRequestDispatcher("maybe/relative")

 

Forward

  • <jsp:forward .../>, RequestDispatcher.forward() are refered as "Server-side"

Redirect

  • Client side redirect

 

Authenticate

  • Basic - not encrypted, password saved in plain text
  • Digest - encrypted
  • Client-Cert - end user authenticate using HTTPS, require user to possess public key certificate (PKC)
  • Form - form method: POST, action: j_security_check, username field: j_username, password filed: j_password

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics