Home > Archive > Java Beans > December 2005 > Why MUST a JSP bean in a package
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Why MUST a JSP bean in a package
|
|
| goelshek@gmail.com 2005-12-02, 9:11 pm |
| After a lot of debugging I realized that if using Tomcat, a JSP bean
must always be in a package. i.e.
<jsp:useBean id = "bean" scope = "session" class = "packageName.myBean"
/>
and
package packageName;
public class myBean
{
......
}
is required to have everything working fine and the directory structure
must be WEB-INF/classes/packageName/myBean.class
WHY is it this way?
why not just have
<jsp:useBean id = "bean" scope = "session" class = "myBean" />
and
public class myBean
{
......
}
and the directory structure looking like WEB-INF/classes/myBean.class
This might be more of a theoretical or "historical context" kinda
question.
I just like to know how and why things are. More so in this case
because HAVING to put a JAVA file (a bean, after all, is just a JAVA
file) doesn't really make sense.
Abhishek
| |
| Thomas Hawtin 2005-12-02, 9:11 pm |
| goelshek@gmail.com wrote:
> After a lot of debugging I realized that if using Tomcat, a JSP bean
> must always be in a package. i.e.
Every class is in a package. If a class doesn't have a package declared,
it'll end up in a default package. You shouldn't be able to import from
a default package (although early compilers allowed it), and there is no
syntax to qualify a class name as being in a default package.
Also note, your compiled JSP will be in a package, with a name given to
it by the JSP engine.
Tom Hawtin
--
Unemployed English Java programmer
http://jroller.com/page/tackline/
|
|
|
|
|