• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Usebean: Fully qualified class name only?

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1>Is it necessary that we always pass the fully qualified classname to the class attribute in useBean?

i.e. Why can't we replace:
<jsp:useBean id="bean1" class="bean.SimpleBean" />
with
<%@ page import="bean.*" %>
<jsp:useBean id="bean1" class="SimpleBean" />
(assuming SimpleBean class is in the bean package.)

2> A jsp spec says that it should be fully qualified name only?
3> If yes, is it not a design flaw so to say?
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1> Yes it is necessary
2> The JSP specification is clear about this : refer to JSP.5.1 <jsp:useBean>
3> A flaw ? Why do you think this would be ?
 
manoj rajkumar
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, we could have specified the directories to look for in
<@page import="dName">
and then used only the class name in the useBean directive.

When I said flaw, I meant lacking flexibility.

Is there any reason why we should specify the fully qualified class only?
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How would using an unqualified name make it more flexible?
 
manoj rajkumar
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ben, In the java classes , we generally have import java.io.* and then use PrintWriter,OutputStream etc. instead of fully qualified class name everywhere else.

Java class:

import java.io.*;
.
.
.
PrintWriter out= ... // Note Fully qual. name not required here.
FileInputStream fin=...

so we could have done something similar to that:
Jsp:

<@page import="com.manoj.myPackage.*">
<jsp:useBean id="bean1" class="ManojBean" />
|
|
Fully Qualified name not required since we are importing


I was thinking in that perspective. But I guess it is just a decision that the designers of the jsp have made and we can follow up with the fully qualified class name.
 
For my next feat, I will require a volunteer from the audience! Perhaps this tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic