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 Doubt in JSP standard tag 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 "Doubt in JSP standard tag" Watch "Doubt in JSP standard tag" New topic
Author

Doubt in JSP standard tag

Ashok Pradhan
Ranch Hand

Joined: Dec 17, 2007
Posts: 180

When I write


it shows error
my bean class Person is in default pacakge(no package)

but keeping everything same when I write

it works perfectly
I have changed my bean class Person default package to ashok package(Person class in ashok package)

I have doubt that the bean class should always be placed in a package ?if so why ?
Piotr Nowicki
Ranch Hand

Joined: Jul 13, 2010
Posts: 610

Generally the default package usage is discouraged, but I guess that the question is still valid...


OCP Java SE 6 Programmer, OCM Java SE 6 Developer, OCE Java EE 6 JSPSD, OCE Java EE 6 EJBD, OCE Java EE 6 JPAD, Spring 3.0 Core Professional.
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1665
    
  25

Yes, the bean should be defined in a package.

This is to avoid instantiating the "wrong" bean ( if two beans with the same name are defined in the default package, for example your MyBean and somebody else's MyBean which is packaged in a .jar file inside your web-application, which one did you mean to be used with your jsp:UseBean....).

Have a look here Syntax jsp:UseBean
<jsp:useBean
id="beanInstanceName"
scope="page | request | session | application"
{
class="package.class" |
type="package.class" |
class="package.class" type="package.class" |
beanName="{package.class | <%= expression %>}" type="package.class"
}
{
/> |
> other elements </jsp:useBean>
}

Regards,
Frits
Ashok Pradhan
Ranch Hand

Joined: Dec 17, 2007
Posts: 180

thanks to all !!!
 
Don't get me started about those stupid light bulbs.
 
subject: Doubt in JSP standard tag