User Guide
318 Developing Web Applications with ColdFusion
getAttribute
public String getAttribute(String name)
Retrieves the value of the passed attribute. Returns an empty string if the attribute
does not exist (use attributeExists to test whether an attribute was passed to the
tag). Use getAttribute(String,String) to return a default value rather than an empty
string.
The following example retrieves an attribute named DESTINATION and writes its
value back to the user:
String strDestination = request.getAttribute("DESTINATION") ;
response.write( "The destination is: " + strDestination ) ;
Parameters:
name — The attribute to retrieve (case insensitive)
Returns:
The value of the attribute passed to the tag. If no attribute of that name was passed
to the tag then an empty string is returned.
See Also:
attributeExists, getAttributeList, getAttribute(String,String),
getIntAttribute
getIntAttribute
public int getIntAttribute(String name)
throws NumberFormatException
Retrieves the value of the passed attribute as an integer. Returns -1 if the attribute
does not exist. Throws a NumberFormatException if the attribute is not a valid
number. Use attributeExists to test whether an attribute was passed to the tag. Use
getIntAttribute(String,int) to return a default value rather than throwing an
exception or returning -1.
The following example retrieves an attribute named PORT and writes its value
back to the user:
int nPort = request.getIntAttribute("PORT") ;
if ( nPort != -1 )
response.write( "The port is: " + String.valueOf(nPort) ) ;
Parameters:
name — The attribute to retrieve (case insensitive)
Returns:
The value of the attribute passed to the tag. If no attribute of that name was passed
to the tag then -1 is returned.