• Post Reply Bookmark Topic Watch Topic
  • New Topic

Doubt in jsp:useBean attribute 'type'

 
Sreeraj G Harilal
Ranch Hand
Posts: 310
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My doubt is about the type attribute in <jsp:useBean>

Here is 3 classes


suppose file 'DisplayOrSetBussinessAddress.jsp' contains

File "DisplayOrSetResidentialAddress.jsp" contains == (code that checks if any session contains attribute named 'address' then display details)



It will definitly cause an error. Then
My doubt is, what is the use of "type" attribute in <jsp:useBean>???
 
Chethan Verma
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sreeraj,

You are trying to access a method in subclass from superclas.
 
Arvind Giri
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


means

<% AddrssBean address = (AddressBean)session.getAttribute("address");
if (address == null)
{
address = new ResidentialAddressBean();
}

%>

and about uses of type attribute, I found basically three uses:
1. When you only want to use an existing object, i.e. you don't want to create a new object.
2. Sometimes it may happen that you know only type (typical interface programming) of object and object would be provided at run time, then only choice left is to use type attribute.
3. Yes, we do not get great advantage when using both type and class attribute, but sometimes it may happen that you want to use super class features only, coz some other programmer working on some other component can access only that. In that case type attribute will prevent you from using method specific to sub class.

Hope it helps....
[ November 21, 2006: Message edited by: Arvind Giri ]
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!