Tuesday, November 8, 2011

Request, Response, getParameter, getAttribute

All the above four terms are not so difficult. But for me sometimes they create a jam in my brain. To solve this jam..

Request : From Client to Server
Response: From Server to Client
Server: Receive Request and Send Response
Client: Send Request and Receive Response


Now,about getParameter()

when we submit a form they all the info is send to action element(resource) of the form. On the context of action element if we want to get the information of the submitted form, we should use

request.getParamater()

So request.getParameter() will retrieve a value that the client has submitted. You will get the value on the server side.

request.getAttribute(), this is all done server side. YOU add the attribute to the request and YOU submit the request to another resource, the client does not know about this. So all the code handling this would typically be in servlets.

No comments: