0% found this document useful (0 votes)
43 views8 pages

Handling The Client Request: Form Data Objectives

This document discusses different methods for handling client requests in Java web applications. It describes how to read single parameter values using getParameter(), read multiple values using getParameterValues(), and get all parameter names using getParameterNames() or getParameterMap(). It also covers setting the character encoding, using default values for missing parameters, and accessing request data directly through getReader() or getInputStream().

Uploaded by

api-3775545
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPS, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views8 pages

Handling The Client Request: Form Data Objectives

This document discusses different methods for handling client requests in Java web applications. It describes how to read single parameter values using getParameter(), read multiple values using getParameterValues(), and get all parameter names using getParameterNames() or getParameterMap(). It also covers setting the character encoding, using default values for missing parameters, and accessing request data directly through getReader() or getInputStream().

Uploaded by

api-3775545
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPS, PDF, TXT or read online on Scribd
You are on page 1/ 8

 Handling The Client Request:

FORM DATA
 Objectives
 Reading individual request
parameters
 Reading entire set of request
parameter
 Handling missing and malformed data
 Reading single values:
 To read a request parameter, you simply
call the getParameter() methods of
HttpServletRequest, supplying case-
sensitive parameter name.
 An empty String is returned if parameter
exists but it does not have any value.
 Null is returned if there was no such
parameter.
 getParameterValues()
 If same parameter name might
appear in the form data more than
once, you should call
getParameterValues() instead of
getParameter()
 The return value of
getParameterValues is null for non
existent parameter names and is a
none element array when
 getParameterNames() and
getParameterMap()
 The getParameterNames() returns an empty
Enumeration(not null) .
 Enumeration is an interface that merely
guarantees that actual class will have
hasMoreElements and nextElement.
 An alternative to getParameterNames is
getParameterMap. This method returns a
Map.
 Reading input in multiple character
sets: setCharacterEncoding()
 By default request.getParameter
interprets inp1ut using the server’s
current character set. To change the
default use setCharacterEncoding()
method of ServletRequest.
 Using default values when
parameters are missing
 The value is null
 The value is an empty string
 The value is not empty string of
wrong format.
 getReader() or getInputStrem() :
instead of reading individual form
parameters you can access query
data directly by using getReader()
or getInputStream() methods.

You might also like