Servlet request

2017-09-05 17:05:47

Fetch URL


Parameter List

  • Request in GET

    result: a=1&b=2
  • Request in POST or GET

  1. getParameter()
    This method limited in form’s encoding
    only used in application/x- www-form-urlencoded
    Advantage is very simple, disadvantage is not suit in big data.
    When transfer big data block browser use multipart/form-data

  2. getInputStream() getReader()
    Get context by stream, got bytes or characters

Stream way have conflict with parameter way
When getParameter() read a from encoded by application/x- www-form-urlencoded once
getInputStream() can’t read data any more.vice versa.

When getParameter() read a from encoded by multipart/form-data, can’t read data
So multipart/form-data encoding have no conflict.

PS. request.getInputStream() request.getReader() can’t use in mix or throw exception

About request.getAttribute()

  1. Attribute is survive in container
  2. HttpServletRequest only have setAttribute() on setParameter()
  3. Survive in one request, like forward
  4. session.setAttribute() have Affect in a progress
  5. If from’s data come’s from JS, use a hidden div parse data -_-!!!