This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes confusion in declaration Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "confusion in declaration" Watch "confusion in declaration" New topic
Author

confusion in declaration

srinivas.b
Ranch Hand

Joined: Oct 26, 2006
Posts: 58
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

Joined: Dec 26, 2007
Posts: 59
Because jsp documents does not support scripting . It has a special tag for declaration which is mentioned in your option 'a'.


SCJP 5.0<br />SCWCD 5.0
srinivas.b
Ranch Hand

Joined: Oct 26, 2006
Posts: 58
is there any difference between JSP Documnet and JSP page ?

if they are same then scripting is valid by default.
Reesha Ashok
Ranch Hand

Joined: Apr 05, 2008
Posts: 32
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


Thanks & Regards,<br />Reesha
Ash More'
Ranch Hand

Joined: Apr 20, 2008
Posts: 47
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: confusion in declaration