Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

confusion in declaration

 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For manageability purpose,you have been told to add a "count instance variable to a critical JSP document so that a JMX MBean can track how frequent this JSP is being invoked.Which JSP code snippet must you use to declare this instance variable in the JSP Documnet?

a)<jsp eclaration>
int count=0;
<jsp eclaration>

b)<%! int count=0;%>

the right answer is "a" why not "b" ?
 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because jsp documents does not support scripting . It has a special tag for declaration which is mentioned in your option 'a'.
 
srinivas.b
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
is there any difference between JSP Documnet and JSP page ?

if they are same then scripting is valid by default.
 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A normal Jsp is a 'page'. If it's written with XML alternatives to normal Jsp syntax (scripting), it's called a 'document'
For a declaration,
Normal jsp page syntax is

Jsp Document syntax for the same is


Please refer to jsp 2.0 spec for a more clear picture on XML view of a Jsp page.There's a chapter on XML View - page # 1-201
 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if you are planning to give SCWCD, then read any certification book, you should know these differences between JSP page and document.

1)<jsp irective.page attributeList/> in JSP document
<%@page attributeList %> in JSP page

2)<jsp irective.include attributeList/> in JSP document
<%@include attributeList %> in JSP page

3)<%@taglib attributeList %> in JSP page. NO <jsp irective.taglib attributeList/> in JSP document.use jsp:root to declare uris for custom libraries.

4)<%= %> in JSP page while <jsp eclaration></jsp eclaration> in JSP document

5)<% %> in JSP page while <jsp:scriptlet></jsp:scriptlet> in JSP document

6)<%! %> in JSP page while <jsp eclaration></jsp eclaration> in JSP document.

7)<jsp:text> some text </jsp:text> in JSP document while in JSP just some text.
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic