• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question on JspContext?

 
hasan khan
Ranch Hand
Posts: 223
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
some confusion about javax.servlet.jsp.JspContext.class

as per API http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/jsp/JspContext.html

setAttribute(String name, Object value) => Register the name and value specified with PAGE SCOPE semantics

getAttribute(String name) => Returns the object associated with the name in the PAGE SCOPE or null if not found.

removeAttribute(String name) => Remove the object reference associated with the given name from ALL SCOPES.

setAttribute() and getAttribute() methods of JspContext.class sets and gets the attribute from PAGE SCOPE

but as per API removeAttribute() will remove the object from ALL the scopes,

is it right ? i just want to confirm

or it should be remove the object from PAGE SCOPE
 
shiva viswanathan
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI Hasan ,

Yes , thats right .

I just checked in the specs and it was clearly metioned
Here is the exact statement
-------------------------------------------------------------
public abstract void removeAttribute(java.lang.String name)
Remove the object reference associated with the given name from all scopes.
Does nothing if there is no such object.
Parameters:
name - The name of the object to remove.
Throws:
NullPointerException - if the name is null


public abstract void removeAttribute(java.lang.String name, int scope)
Remove the object reference associated with the specified name in the given
scope. Does nothing if there is no such object.
Parameters:
name - The name of the object to remove.
scope - The scope where to look.
Throws:
IllegalArgumentException - if the scope is invalid
IllegalStateException - if the scope is PageContext.SESSION_SCOPE but the
page that was requested does not participate in a session or the session has
been invalidated.
NullPointerException - if the name is null

-------------------------------------------------------------

THanks for pointing it out . Even i didnt know that

Catch You Later
Shiva
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic