JSP Implicit Objects

Discussion in 'Java' started by marcwentink@hotmail.com, Jul 25, 2006.

  1. Guest

    I am reading something about JSP Implicit Objects, objectslike for
    example:

    request, response, pageContext, application, out, session

    But then my tekst book says:

    ---------------------------------------------------------------------------------
    Note that these implicit objects are only visible within the system
    generated
    _jspService() method. They are not visible within methods you define
    yourself in
    declarations.
    -------------------------------------------------------------------------------

    Ok, then this means I cannot use them? If so why mention them anyway?
    Can you use them somehow?

    Marcus Wentink
    , Jul 25, 2006
    #1
    1. Advertising

  2. Guest

    it is easy to use them, you don't have to write methods in a JSP file
    for example
    <%

    if ( "true".equals(request.getParameter("largetext")))
    out.println("<font size=7>LARGE TEXT</font>");


    %>

    one thing I did when I wrote a method was to pass in the request as a
    parameter...
    for example...

    <%!

    public boolean isLargeText(HttpServletRequest request)
    {
    return "true".equals(request.getParameter("largetext"));
    }

    %>

    then you can write this code below where you need it

    <%

    if ( isLargeText(request) )
    out.println("<font size=7>LARGE TEXT</font>");

    %>


    hope this helps

    -ReLipse
    Xhirl Software Design
    www.xhirl.com/software

    wrote:
    > I am reading something about JSP Implicit Objects, objectslike for
    > example:
    >
    > request, response, pageContext, application, out, session
    >
    > But then my tekst book says:
    >
    > ---------------------------------------------------------------------------------
    > Note that these implicit objects are only visible within the system
    > generated
    > _jspService() method. They are not visible within methods you define
    > yourself in
    > declarations.
    > -------------------------------------------------------------------------------
    >
    > Ok, then this means I cannot use them? If so why mention them anyway?
    > Can you use them somehow?
    >
    > Marcus Wentink
    , Jul 25, 2006
    #2
    1. Advertising

  3. Guest

    schreef:

    > one thing I did when I wrote a method was to pass in the request as a
    > parameter... for example...


    Ok so the text in the book tries to explain that if you use it in a
    function you defined, the object is not there, unless you have passed
    it as a parameter.....since in this defined function you are in another
    scope.

    In 'normal' java code snippets in JSP files on the other hand, they are
    available.

    Bad bad book!

    Thanks a lot!
    , Jul 25, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matthias Nietz
    Replies:
    1
    Views:
    3,443
    VisionSet
    Nov 12, 2003
  2. Raymond DeCampo

    Custom tags and <jsp:plugin> / <jsp:param>

    Raymond DeCampo, Feb 18, 2004, in forum: Java
    Replies:
    0
    Views:
    624
    Raymond DeCampo
    Feb 18, 2004
  3. cvelusc
    Replies:
    5
    Views:
    3,622
    Sudsy
    Jun 3, 2004
  4. Replies:
    0
    Views:
    4,353
  5. 7stud
    Replies:
    11
    Views:
    688
    Dennis Lee Bieber
    Mar 20, 2007
Loading...

Share This Page