This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSP and the fly likes JSP  usebean type Vs class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP  usebean type Vs class " Watch "JSP  usebean type Vs class " New topic

JSP usebean type Vs class

Awais Bajwa
Ranch Hand

Joined: Jan 16, 2001
Posts: 191
Hi folks,
Can anybody explain the difference between the "type" and "class" attributes in <jsp:usebean> tag.

Stefan Evans

Joined: Jul 06, 2005
Posts: 1016
Its all explained here:

In short:
"type" specifies the type of the scriptlet variable created.
"class" specifies the class of the variable to be created if it is null.

a contrived example:
<jsp:useBean id="date" type="java.util.Object" class="java.util.Date"
Object date = new java.util.Date();
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60766

A slightly more up-to-date "syntax card":
[ March 20, 2006: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
It is sorta covered in the JavaRanch Style Guide.
subject: JSP usebean type Vs class
Similar Threads
Ridiculous Syntax in JAVA generics
Clarification in Class Type's in Java
Difference between
About type and class attribute of jsp usebean
How to typecast an object which is of unknown class type at runtime?