Java (current. Jakarta) Server Pages is a framework used for web application development.

This post will discuss:

  • Request Object and Methods


Request Object


The request object in JSP is used for:

  1. Reading info from the client
  2. Letting the server read info
  3. Reading parameters from a client request
  4. Reading the data on cookies

In other words, it deals with the interactions between a client and its server.

These are more general methods:

Methods for request object:

getContextPath()
Gets the path for the request object.
setMethod();
Sets the method by which the request is communicated.
getServerName():
Gets server name.
getServerPort();
Gets port number.
getRequestURL/URI()
Gets server URL.
getRemoteAddr();
Gets remote address.
getProtocol();
Gets the protocol used. (Between client, server)


The essential methods for the request object, however, are those that handle data communicated over pages by the request object:

Methods for request object:

getParameter():
Gets the parameters passed by the request, by key/name.
getParameterValues():
Gets all values passed by the request.
getParameterNames():
Gets all keys in enum.
getParameterMap():
Gets map object. Contains the keys and corresponding values.


The request object is called from inside the document. The input field must specify the name and type values.

<form action="recipient_page.jsp" method="get/post"></form>



And can then be handled. The value of the request is saved to the defined variable.

String a = request.getParameter("abc");



-gonkgonk


<
Previous Post
Java Server Pages - Expression Tag, Directive Tag, Inline Comments
>
Next Post
Java Server Pages - Response Object, Cookie Object