I don't understand why ServletRequest has a setAttribute method. Eg: if i have a jsp page containing 1 textbox and a submit button...
My objective is when i submit my name should be displayed in that textbox. Question here: whatever is displayed in that textbox is response from servlet right?
But in my assignment in servlet part: It was written request.setAttribute("name","abc");
at jsp side:
It was written: <input type="text" value = < %request.getAttribute("name")% > >
I know in javadocs they have setattribute inside request but why not under response?
Request : From Client to Server
Response: From Server to Client
When your client sends your servlet request, you add object in request and later retrieves it in jsp.The request is passed from servlet to jsp.Your jsp retrieves the object,generates a HTML and sends it as response back to your browser.The same request sent by your client is passed from one servlet or jsp to another jsp or servlet and then these are compiled to generate HTML format and sent to browser as response from server.Setting object in response doesnot make sense because browser just displays HTML.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With