1.The exact difference between attributes and parameters in regard with servlets?
2.Also if i set the attributes by using setAttribute in a servlet and get it back by using getAttribute in a jsp/servlet then are they completely removed? 3.Or are they available in other jsp's/servlets? 4.Is this thing depend on the scope(session/request etc) for which attributes are set?
Thanks in Advance
SCJP 1.4 (86%)<br />SCWCD 1.4 (86%)<br />----------<br />If You dont succeed at first time,call it Version 1.0 !!!
getParameter returns the value of the HTML Form or Querystring parameters as a string. You don't set them on the server side (for the most part).
The getAttribute and setAttribute methods allow you to bind and retrieve objects to the desired scope.
No, calling getAttribute doesn't remove it from that scope.
And no, the behaviour doesn't vary among the different scopes. The lifecycle of the different scopes DOES vary and this can affect the availablility of an object bound to that scope. For instance, if you bind an object to request, you won't be able to retrieve it after that request cycle is complete (from another request).
1. request parameters are set when the servlet container analyzes the request before your code sees it, and can not be changed. request attributes can be attached to a request by your code. 2. getAttribute gets a copy of a reference to an object - reading the API will reveal that there is a specific removeAttribute method 3,4. request attributes are attached to a request and have no meaning beyond a single request-response cycle. See the HttpSession documentation for session scope attributes Bill
Joined: Apr 01, 2005
Thanx to u guys
This clears the confusion......
subject: Difference between attributes and parameter