Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sybex (again) question

 
friso jonge
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
chap 9, question 6 : which of the following declaration types is not legal to use within a scriptlet tag ?
1 if block
2 method
3 variable
4 code block
well the answer given is : method. I can agree with that but would like some clarification.
The book mentions: (page 312)
A scriptlet is a piece of code, that can have multiple statements, variable declarations, code blocks (not static) and conditional or iterative statements.
later is mentions: (page 314)
within a scriptlet, you can include the following tag types..
- declarations (variable, method, class)
- expressions
- any implicit or explicit object decalrd with usebean
- any valid scripting language statement
So my question, what is the difference in tag types declaration of a method, and the normal inclusion of a method (which is not allowed)?
thanks,
friso
 
Mikalai Zaikin
Ranch Hand
Posts: 3371
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
method declarations are definitely NOT allowed inside scriptlets, since its code will be inserted "as is" inside _jspService(...) method.
[ November 02, 2002: Message edited by: Mikalai Zaikin ]
 
Hafizur Rahman
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mikalai Zaikin:
Hi,
Scriplets<% %> and declarations<%! %>should not be confused. Scriptlets go inside the _jspService method. On the other hand, declarations go as member variable and methods. So scriplets cannot contain methods. And declarations cannot access implicit objects directly. Please see any generated java file.
 
Hafizur Rahman
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I m new to posting answers here. So dont be confused with the above.
Scriplets<% %> and declarations<%! %>should not be confused. Scriptlets go inside the _jspService method. On the other hand, declarations go as member variable and methods. So scriplets cannot contain methods. And declarations cannot access implicit objects directly. Please see any generated java file.
 
See El
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It (scriptlet) can contain class declaration (and within it, methods declaration) of (inner) local class though. In example :

[ November 07, 2002: Message edited by: See El ]
[ November 07, 2002: Message edited by: See El ]
 
Maha Annadurai
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A syntax error in above code.
It should be
new Inner() .nothing(out);
-Maha
[ November 09, 2002: Message edited by: Maha Annadurai ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic