Jashua Ni wrote:

> Hi, all:
>
> I could not find the definition for the following:
>      inside a servlet service()  function,  request.setAttribute("key",
> Object),  when this servlet call a jsp, inside jsp, <%Object
> o1=(Object)reqest.getAttribute("key"), then every function and variable from
> o1 is available to be used inside jsp?
>
>      Is this a jsp specification? where can I find the definition for this?
> Thanks in advance.
>
>     Jashua Ni
>

Because a JSP page is compiled into a servlet, your scriptlets can do everything a
servlet can.  I suggest you take a look at the Servlet API Specification (version
2.1 is current, version 2.2 will be soon -- it is also a lot more thorough in its
coverage of these issues), available at:

    http://java.sun.com/products/servlet

The particular call you are talking about is a method of ServletRequest (which
HttpServletRequest extends).  It is quite useful when you want to pass objects to
a JSP page (or servlet) that you are either including (<jsp:include>) or
forwarding to (<jsp:forward>).  If you forward to a servlet, it can use
request.getAttribute() to access this object.  If you forward to a JSP page, it
can use <jsp:useBean id="key" scope="request" ...> to access the object.

The Java Language Tutorial also has a nice introduction to Servlets that helps you
understand the basic concepts:

    http://java.sun.com/docs/books/tutorial

Craig McClanahan


>
> ===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
> FAQs on JSP can be found at:
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to