• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Using type without class - page 354

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happens when we declare a type, but not a class ?

JSP
<jsp:useBean id="person" type="foo.person" scope="page" >

Result if the person attribute already exists in "page" scope:

It works perfectly

Result if the person attribute does not exist in the "page" scope:

javax.servlet.ServletException: bean person not found within scope


I am not able to understand - what will make the person attribue available in the page scope (for the above JSP) ?

Thanks
 
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

JSP
<jsp:useBean id="person" type="foo.person" scope="page" >

1. Result if the person attribute already exists in "page" scope:

It works perfectly

2. Result if the person attribute does not exist in the "page" scope:

javax.servlet.ServletException: bean person not found within scope


1. This work perfectly because it will be able find a request attribute and it will try to work on that bean.

2. If it will not find any beans with the name person then it will throw ServletException.

All this is about having the bean already in scope.

If we exchange 'type' with 'class', then it will look for the bean and it doesn't find it in scope then it will make it available in the scope.
 
Don't touch me. And dont' touch this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic