在开发jsp时,有的变量不需要预先声明就可以在脚本代码和表达式中随意使用
如:request (HttpServletRequest类型)
handler.process(request);
实际开放中用到的方法API说明:
setAttribute (Methods inherited from interface javax.servlet.ServletRequest)
public void setAttribute(java.lang.String name,
java.lang.Object o)
Stores an attribute in this request. Attributes are reset between requests. This method is most often used in conjunction with RequestDispatcher.
Attribute names should follow the same conventions as package names. Names beginning with java.*, javax.*, and com.sun.*, are reserved for use by Sun Microsystems.
If the object passed in is null, the effect is the same as calling removeAttribute(java.lang.String).
It is warned that when the request is dispatched from the servlet resides in a different web application by RequestDispatcher, the object set by this method may not be correctly retrieved in the caller servlet.
Parameters:
name - a String specifying the name of the attribute
o - the Object to be stored