I'm not able to visualize the difference between the request attribute and request parameter as I have a vague idea that both are more or less the same. The scope of request attribute is also only to the page that e forward the request and the same for request parameter. So why do we need request attributes explicitly??
Anyone on this please??
SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Ok, I can understand the basic difference between the types Object type for attributes and String types for parameters. But other than this both have the same cope of making the value only visible to the page they are being forwarded. Am I right on this??
As long as your request object is in scope request attributes are also in scope.You can set attribute in one servlet and get same object in another servlet. In servlets the HttpServletRequest has lowest scope visiblity. Next highest scope visiblity has HttpSession Last scope ServletContext has high degree of scope visiblity.
My question is can I set a request attribute in one servlet and forward that using Request Dispatcher to servlet 2 and can I try to access that request attribute from any other servlet to which I have not forwarded the request??
It is called request attribute because it is available during the duration of a request, to all servlets that may be involved (directly, through forward or include). A servlet that hasn't seen the request can't access the attribute.
as the name implies Request Attribute will be having the scope of Request and Request only. it dies along with the Request. if you want its scope to be extended .. may be you can go for broader scopes such as session. [ January 03, 2007: Message edited by: poorna prakash parvathala ]