What is the difference between attribute and parameter?

An attribute is an object which can be bounded into three other servlet objects- HttpServletRequest, HttpSession, ServletContext.
You can think of it as a name value pair where name is String and value is Object. It can have three types of scope- context,request,session

Remember attributes are not parameters:
In attribute you can share an object but in case of parameter you can share a string.
For setting attribute the method setAttribute() is used but for parameter there is no method, should be set in the DD.
The return type of attribute(getAttribute()) is Object but for parameter(getInitParameter()) it is String.

1 comment:

  1. Try not to become a man of success, but rather try to become a man of value. See the link below for more info.


    #value
    www.ufgop.org

    ReplyDelete