You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Mufaddal Khumri <mu...@wmotion.com> on 2003/03/03 06:44:25 UTC
Re: Am i doing something wrong while using ?????
I downcasted but it did not help.
<jsp:useBean id="faqHelper" class="FAQHelper" scope="session">
<jsp:setProperty name="faqHelper"
property="dbReader"
value="<%= (Object)session.getAttribute("DBREADER")%>" />
<jsp:setProperty name="faqHelper"
property="dbWriter"
value="<%= (Object)session.getAttribute("DBWRITER")%>" />
</jsp:useBean>
I went to the generated .Java file for the JSP .. its throwing an
exception at this line :
if (pageContext != null) pageContext.handlePageException(t);
On Monday, March 3, 2003, at 11:24 PM, Erik Price wrote:
>
>
> Mufaddal Khumri wrote:
>
> [...]
>
>> In my JSP page i have the following code
>> /
>> /---------------------------------------------------------------------
>> -- ----------------
>> <jsp:useBean id="myBean" class="MyBean" scope="session">
>> <jsp:setProperty name="faqHelper"
>> property="dbReader"
>> value="<%=
>> session.getAttribute("DBWRITER")%>" />
>> <jsp:setProperty name="faqHelper"
>> property="dbWriter"
>> value="<%=
>> session.getAttribute("DBWRITER")%>" />
>> </jsp:useBean>
>> /
>> /---------------------------------------------------------------------
>> -- ----------------
>> I get the following error in my log file:
>> 2003-03-03 10:23:51 StandardWrapperValve[jsp]: Servlet.service() for
>> servlet jsp threw exception
>> org.apache.jasper.JasperException: FAQHelper
>
>
> In your <jsp:setProperty> tags, the "name" attribute should be the
> same as a JavaBean instance identified with the "id" attribute of
> <jsp:useBean>.
>
> So maybe it should look like this:
>
> <jsp:useBean id="faqHelper" class="MyBean" scope="session"/>
> <jsp:setProperty name="faqHelper" property="dbReader"
> value="<%= session.getAttribute("DBWRITER") %>"/>
>
> etc.
>
> Also you may need to downcast the value returned from
> session.getAttribute().
>
>
> Erik
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Am i doing something wrong while using
?????
Posted by Erik Price <ep...@ptc.com>.
Mufaddal Khumri wrote:
> I downcasted but it did not help.
> <jsp:useBean id="faqHelper" class="FAQHelper" scope="session">
> <jsp:setProperty name="faqHelper"
> property="dbReader"
> value="<%=
> (Object)session.getAttribute("DBREADER")%>" />
> <jsp:setProperty name="faqHelper"
> property="dbWriter"
> value="<%=
> (Object)session.getAttribute("DBWRITER")%>" />
> </jsp:useBean>
That's not downcasting, because the "getAttribute" methods return their
values as type Object by default. Unless you really are storing
instances of Object in your session.
I also noticed that your FAQHelper class is not in a package. IIRC you
need to package all of your classes as of Java 1.4.
Go to the FAQHelper class, use a package declaration to put it into a
class, similar to this:
package com.wmotion.mypackage;
Now in your JSP you should use the following syntax:
<jsp:useBean id="faqHelper" class="com.wmotion.mypackage.FAQHelper"
scope="session">
<jsp:setProperty name="faqHelper" property="dbReader"
value="<%=(MySpecialSubclass)
session.getAttribute("DBREADER")%>"/>
<jsp:setProperty name="faqHelper property="dbWriter"
value="<%=(MyOtherSubclass)
session.getAttribute("DBWRITER")%>"/>
</jsp:useBean>
Hope that helps
Erik
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org