aspose file tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes <jsp:useBean> unexpected behavior Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Professional Certification » Web Component Certification (SCWCD/OCPJWCD)
Reply Bookmark "<jsp:useBean> unexpected behavior" Watch "<jsp:useBean> unexpected behavior" New topic
Author

<jsp:useBean> unexpected behavior

Shwetha Sharma
Ranch Hand

Joined: Jun 01, 2008
Posts: 34

In servlet if we have


jsp code :


In the generated servlet:


Runtime exception is thrown



and in case we have something apart from null in the request attribute:


the generated servlet has:


Why the null condition has diffeent behaviour in both cases in the generated servlet?

SCJP6:80%, OCWCD 88 %
Royston Monteiro
Ranch Hand

Joined: Apr 25, 2008
Posts: 35
Whooaah! Very strange.

From what I have learnt, I think the generated servlet for a given jsp should be the same irrespective of what some other servlet does before calling it.

Could someone please clarify.

ps: which container are you using?



Cheers,
Roy.
SCJP 1.5, SCWCD 5.
"Perseverance is the hard work you do after you get tired of doing the hard work you already did"
Chinmaya Chowdary
Ranch Hand

Joined: Apr 21, 2008
Posts: 432
Hi, Shwetha.

Can you please post, how you are accessing jsp:useBean in the above case?
Shwetha Sharma
Ranch Hand

Joined: Jun 01, 2008
Posts: 34

I missed the difference in usage.

If we dont specify the class attribute for the jsp:use bean, then Instanciation Exception is thrown in case the bean is not present in session or its null




results in



and in case we give class attribute


results in


Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
From the syntax ref:

The <jsp:useBean> element locates or instantiates a JavaBeans component. <jsp:useBean> first attempts to locate an instance of the Bean. If the Bean does not exist, <jsp:useBean> instantiates it from a class or serialized template.
 
 
subject: <jsp:useBean> unexpected behavior
 
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture