File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Bean is already there or not 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 "Bean is already there or not" Watch "Bean is already there or not" New topic

Bean is already there or not

Amandeep Singh
Ranch Hand

Joined: Jul 17, 2008
Posts: 850
The following jsp page intends to print the name of the Account. Which of the given options accomplish this task correctly?
(The code for is given in exhibit. )

<h1>Simple Bean Usage</h1>
com.enthuware.jwebplus.Account acct = new com.enthuware.jwebplus.Account(1, "Bob", 1000.0);
pageContext.setAttribute("account", acct);

Account Name is : <<< INSERT CODE HERE >>>

This is from enthuware. In the answer's hint, it is written that this bean is already existing. How can i find in the quesiton that it say's that the bean is already there.

This is from ENhtuware.

Please advise.

SCJP 1.4, SCWCD 5, SCBCD 5, OCPJWSD 5,SCEA-1, Started Assignment Part 2
My blog-
Atul Samnerkar
Ranch Hand

Joined: Sep 20, 2003
Posts: 44

When you create Bean object in the scriptlet, then it is accessible to that JSP.

Being "acct" bean is crated and already exists in the current JSP, you don't need to associate it with pageContext for using on the same page.

If you have other include files / helper classes for this JSP, then you will need to associate bean with pageContext to access other implicit objects from include files / helper classes.

As in the question, the bean is accessed on the same page, hence the hint is correct --> "bean is already existing"

Atul Samnerkar
Amandeep Singh
Ranch Hand

Joined: Jul 17, 2008
Posts: 850
Got it Atul, Thanks once more.
I agree. Here's the link:
subject: Bean is already there or not
jQuery in Action, 3rd edition