The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes page attributes set using jsp:useBean 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 » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "page attributes set using jsp:useBean" Watch "page attributes set using jsp:useBean" New topic

page attributes set using jsp:useBean

subathra sangameswaran

Joined: Nov 19, 2005
Posts: 27
Hi all,
Following is my test jsp. When I use useBean without a scope, i set an attribute at page scope right.
Can I access the same using EL as in line 5?
Can I access the same using scripting as shown in last line?
I have the tld appropriately done for func and my simple tag(bodycontent tagdependent). But call to function is printed as template text and the simple tag bodycontent did not print at all.

My output of the jsp is only this
56789 ${xyz.telephone} ${func.MyFunc()} within doTag:hi!

Where do I err?
Thanks and have a nice day

<jsp:useBean id="xyz" class="com.MyModel" >
<jsp:setProperty name="xyz" property="telephone" value="56789" />
<jsp:getProperty name="xyz" property="telephone"/>
<%@ taglib prefix="func" uri="http://subha/home" %>
<%@ taglib prefix="myst" uri="http://subha/home" %>
<myst:MyST srt="hi!">
<% pageContext.getAttribute("xyz").getTelephone(); %>
<% ((com.MyModel)pageContext.getAttribute("xyz")).getTelephone(); %>

Narendra Dhande
Ranch Hand

Joined: Dec 04, 2004
Posts: 950

I think the EL is not enabled on your container. Also use <%= instead of <% to print the values.

For the Simple tag, unless you use getJspBody.invoke(null) to print the body, it will not print the body.

[ March 29, 2006: Message edited by: Narendra Dhande ]

Narendra Dhande
SCJP 1.4,SCWCD 1.4, SCBCD 5.0, SCDJWS 5.0, SCEA 5.0
subathra sangameswaran

Joined: Nov 19, 2005
Posts: 27
Thank you very much!
I agree. Here's the link: http://aspose.com/file-tools
subject: page attributes set using jsp:useBean
Similar Threads
mock exam question
Get name of bean into .tag file through attribute
using custom tags & tag handler class - URGENT
Taglib uri..problem..(need help)
JBuilder 6 and custom tag-libraries