File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Bean is already there or not

 
Amandeep Singh
Ranch Hand
Posts: 850
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following jsp page intends to print the name of the Account. Which of the given options accomplish this task correctly?
(The code for Account.java is given in exhibit. )

<html>
<body>
<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 >>>
</body>
</html>


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.
 
Atul Samnerkar
Ranch Hand
Posts: 44
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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"

Thanks,
Atul Samnerkar
 
Amandeep Singh
Ranch Hand
Posts: 850
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got it Atul, Thanks once more.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic