Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes JSP and the fly likes declarations fault Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » JSP
Reply locked New topic
Author

declarations fault

tue march
Greenhorn

Joined: Mar 09, 2005
Posts: 16
Hi ppl,

we know that scriptlets and expressions go inside a _jspservice(), and declarations go outside of _jspservice() when a jsp is converted a servlet.

But in one sample programs which i typed and executed, it is showing all the three scriptlets, expressions and declarations all going inside _jspservice().

so can anybody explain which is true either declaration goes inside or not.

i am totally confused.

THanks,
good guy
Annie Smith
Ranch Hand

Joined: Mar 05, 2005
Posts: 172
Is this a beginner question

Anyway, the way it is generated depends on the container implementation.


Cheers!<br /><b>Annie</b>
Ryan McGuire
Ranch Hand

Joined: Feb 18, 2005
Posts: 945
IF I UNDERSTAND CORRECTLY...

It's not what's inside your delimiters that determines where the included code goes; it's what type of delimiter you use:
  • Anything in <% %> delimiters is put inline.
  • Anything in <%= %> is put inline but without closing the current out.print().
  • Anything in <%! %> is put outside of the _jspservice() method.


  • If you want declarations to end up out outside the _jspservice() method, just wrap them in <%! and %>.

    Ryan
    [ May 06, 2005: Message edited by: Ryan McGuire ]
    Ryan McGuire
    Ranch Hand

    Joined: Feb 18, 2005
    Posts: 945
    Originally posted by Annie Smith:
    Is this a beginner question


    Let's say it's an upper beginner level JSP question.
    Joel McNary
    Bartender

    Joined: Aug 20, 2001
    Posts: 1815
    ...But it's JSP, so I'm moving this thread over to that forum.


    Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
    Bear Bibeault
    Author and ninkuma
    Marshal

    Joined: Jan 10, 2002
    Posts: 56222
        
      13

    "tue march", please do not cross-post the same question in multiple forums. It wastes people's time when multiple redundant conversations take place.


    [Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: declarations fault
     
    Similar Threads
    JSTL and declaratives
    help, help, help.
    sybex (again) question
    Mock exam question doubt?
    declaration contents appears in jspservice method