| 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
Rancher
Joined: Apr 07, 2010
Posts: 1066
|
|
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 !!!
|
 |
 |
|
|
subject: Doubt in JSP standard tag
|
|
|