jump to navigation

Attributes August 24, 2005

Posted by Coolguy in Servlets/Jsp.
trackback
  • Attribute is a object bound to other servlet API objects like ServletContext,HttpServletRequest,HttpSession
  • Types:
    Application
    Request
    Session
  • To set an attribute :
    setAttribute(String name,Object value)
  • Method to get:
    getAttribute(String name)
  • Return type:
    Object
  • Scope of attribute:
    Context,
    Session ,
    Request
  • Three attribute scopes Context,Session,Request are handled by ServletContext,ServletRequest,HttpSession interfaces
  • Methods are:
    getAttribute(String)
    setAttribute(String,Object)
    removeAttribute(String)
    getAttributeNames()
  • Context scope attributes are not thread-safe
  • Session scope attributes are not thread-safe as its one thread per request not one per session.
  • To make them thread safe synchronize ServletContext and HttpSession respectively
  • Request variables and local variables are thread safe
  • Instance variables are also not thread safe
Advertisements

Comments»

No comments yet — be the first.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: