File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes jsp:useBean doubt 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 "jsp:useBean doubt" Watch "jsp:useBean doubt" New topic
Author

jsp:useBean doubt

Devendra Joshi
Greenhorn

Joined: Apr 21, 2008
Posts: 8
In 'useBean' action, 'page' scope cannot be used when I am using 'type' attribute and not 'class' attribute.

Is this assumption correct?


Deven<br />SCJP 5 (93%), SCWCD 5(96%), SCBCD 5(98%), SCEA 5 PART-1(96%), Waiting for assignment
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Why ?


[My Blog]
All roads lead to JavaRanch
Devendra Joshi
Greenhorn

Joined: Apr 21, 2008
Posts: 8
scope='page' means a new instance will be created (always), whereas when we use type the object needs to be present with the given name (new object will not be created).
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

The bean could be created before the useBean, although it does not make much sense
Devendra Joshi
Greenhorn

Joined: Apr 21, 2008
Posts: 8
So you mean to say something like this:

<%
MyBean bean = new MyBean();
page.setAttribute("thisBean", bean);
%>

<jsp:useBean id="thisBean" type="MyBean"/>
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Yes, something like pageContext.setAttribute("thisBean", bean);. This looks pointless, doesn't it ?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jsp:useBean doubt