Bosch Ricardo wrote:

> What exactly is the code a  JSP page compiles when you put in a usebean tag.
> Like as if I was trying to use/create  a session bean in  a servlet.  I'd also
> like to come up with some way to redirect a user who directly tries to go to
> page that uses a bean , when they should be coming from a servlet.
>
> thanks
> rick
>

If you are using JSWDK or Jakarta Tomcat, you can set the "keepgenerated" option in
the configuration parameters to keep the generated source code around so you can
look at it.

Basically, the following "scope" settings in a <jsp:useBean> correspond to the
listed servlet API calls:

scope="request"
    ServletRequest.getAttribute();
    ServletRequest.getAttributeNames();
    ServletRequest.removeAttribute();    // 2.2 API only
    ServletRequest.setAttribute();

scope="session"
    HttpSession.getValue();
    HttpSession.getValueNames();
    HttpSession.putValue();
    HttpSession.removeValue();
        // In 2.2, these are deprecated because
        // they are being replaced with methods
        // getAttribute(), getAttributeNames(),
        // removeAttribute(), and setAttribute()
        // for consistency.  The old names still work

scope="application"
    ServletContext.getAttribute();
    ServletContext.getAttributeNames();
    ServletContext.removeAttribute();
    ServletContext.setAttribute();

You will probably notice some consistency in the method names :-).  This is not
accidental -- JSP "beans" correspond to servlet API "attributes" for each of the
corresponding scopes.

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

Reply via email to