• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

confusion in declaration

 
srinivas.b
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • 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" ?
 
Charmy Madhvani
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Reesha Ashok
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • 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
 
Ash More'
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic