CGI

  • Use HttpServletRequest request

GET

String param_value = request.getParameter("param_name");
  • If the parameter was not sent, the value retrieved is null.

POST

String param_value = request.getParameter("param_name");
  • If the parameter was not sent, the value retrieved is null.

Environment variables

String baseUrl   = request.getHeader("Referer");
String host = request.getHeader("Host");
String userAgent = request.getHeader("User-Agent");

HTML forms

Text field

  • If the field is empty, the value retrieved is an empty string.

Radio button

  • If no item was selected, the value retrieved is null.

Check box

  • If the field is unchecked, the value retrieved is null.
  • If the field is checked, the value retrieved is "on".

Single-selection list

  • If no item was selected, the value retrieved is null.

Multiple-selection list

  • The value is retrieved as an array of strings.
  • If no items were selected, the value retrieved is null.