File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Scope Attribute for jsp:set and jsp:get Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Scope Attribute for jsp:set and jsp:get" Watch "Scope Attribute for jsp:set and jsp:get" New topic

Scope Attribute for jsp:set and jsp:get

raja ram
Ranch Hand

Joined: Mar 02, 2008
Posts: 169

I used <jsp:useBean id="operson" class="Person" scope="request" >
<jsp:setProperty name="operson" property="name" value="hi" Scope="request" />
<jsp:getProperty name="operson" property="name" Scope="request" />

But Tomcat throws up an Jsp Compile Time Error saying invalid attribute Scope in jsp:get and jsp:set tags that means we cant specify the Scope Attribute for these tags.

But in HFSJ page number 355 it is stated that the default scope for <jsp:useBean> and <jsp:getProperty> is Page scope I checked Errata nothing is specified about this.

I think we cant have scope attribute specified in the <jsp:setProperty> and <jsp:getProperty> tags.

Musab Al-Rawi
Ranch Hand

Joined: Aug 06, 2007
Posts: 231
There is scope attribute for the setProperty nor getProperty.
you introduce the bean using useBean and there you specify the scope. Now whenever you se/get a property, you will be working on a bean that you have introduced using the useBean. i.e there is no point in having the scope again for get/set properties.

HINT specs.

dhwani mathur
Ranch Hand

Joined: May 08, 2007
Posts: 621
Hi raja ram

i think in your code as per you have shown just note overhere:

May be this is leading to compiler error see below:>

and not

and what Musab Al-Rawi said is absolutely correct
there is no point in giving scope while setting and
getting properties,since we already decide the Bean
scope in UseBean Tag.

I hope it help you to some extent.

SCJP(1.5),SCWCD(On the Way...)
Dhwani:>Winning is not important but it is the only thing.
[ May 06, 2008: Message edited by: dhwani mathur ]
I agree. Here's the link:
subject: Scope Attribute for jsp:set and jsp:get
It's not a secret anymore!