• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt in JSP standard tag

 
Ashok Pradhan
Ranch Hand
Posts: 180
Eclipse IDE Firefox Browser Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 611
1
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Generally the default package usage is discouraged, but I guess that the question is still valid...
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2267
76
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 180
Eclipse IDE Firefox Browser Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks to all !!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic