![]() |
When a Servlet accepts a call from a client, then it receives two objects, one is a ServletRequest and the other is the ServletResponse. ServletRequest encapsulates the Communications from the client to the server, while ServletResponse encapsulates the Communication from the Servlet back to the client. The Object of the ServletRequest is used to provide the client request information data to the Servlet as a content type, a content length, parameter names, and the values, header information and the attributes, etc. ServletRequest allows the Servlet to access information such as:
The Subclasses of the ServletRequest allows the Servlet to retrieve more protocol-based-specific data. For example, HttpServletRequest contains the methods for accessing HTTP-specific based header Information. ServletResponse allows Servlet
Through ServletResponse, the Servlet can send the reply data. The Subclasses of ServletResponse provide the Servlet with more protocol-based-specific capabilities. For example, up ServletResponse can contain methods that allow the Servlet to Control the HTTP-specific header information. Methods of ServletRequest Interface
Example of ServletRequest to display the name of the userIn this example, we are displaying the name of the user in this servlet, And for this, we have used the getParameter method that returns the value for the given request parameter name. We have the use of Servlet – Request Interface in it And When we use it within this example and running will successfully establish the method. newindex.html HTML
MockServer.java Java
|
Reffered: https://www.geeksforgeeks.org
Java |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 10 |