tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pid <...@pidster.com>
Subject Re: [email] Dynamic attachments in mailer taglib 2 using JavaBean
Date Fri, 03 Sep 2010 11:13:48 GMT
On 03/09/2010 04:49, Ferindo Middleton wrote:
> I've written a javabean that connects to a database, downloads a file,
> and one of the getter methods returns the complete file path to the
> file.
>=20
> The problem I have is: when the JSP runs and gets to the part where it
> gets the file path to pass to the taglib, I get an error message that
> is typical of a reference to a nonstatic variable. This concerns me as
> I thout getter methods in javabeans would inherently returns values
> that are valid instance variables in a JSP.
>=20
> I will paste my getter method below, the JSP call to that method and
> the error message below: any guidance is welcome. Thank you:
>=20
> Getter method in jsvabean (javabean compiles fine):
>=20
>                 public String getTempFilePath() {
>                     this.downloadedfilename=3D
> tempFilePath;
>                     return this.downloadedfilename;
>=20
>                   }
>=20
> JSP call to getter method above:
>=20
>         <jsp:useBean id=3D"getFilePath" scope=3D"request"
>         class=3D"hall.RadTicketsFileDownloadForEmailAttachmentBean">
>    <jsp:setProperty name=3D"getFilePath"
>       property=3D"fileId"
>       value=3D"${all_attachments_for_this_ticket_row.id}" />
>=20
>            <jsp:setProperty name=3D"getFilePath"
>       property=3D"originalFileName"
>       value=3D"${all_attachments_for_this_ticket_row.attachment_name}" =
/>
>=20
>         <c:forEach items=3D"${all_attachments_for_this_ticket.rows}"
> var=3D"all_attachments_for_this_ticket_row">
>=20
>=20
>=20
>         <%-- /RadTicketsFileDownloadForEmailAttachment?attachmentId=3D$=
{
> all_attachments_for_this_ticket_row.id}&fileName=3D${all_attachments_fo=
r_this_ticket_row.attachment_name}
> --%>
>         <mt:attach type=3D"application/octet-stream"
>         name=3D"${all_attachments_for_this_ticket_row.attachment_name}"=

>         filename=3D"<%=3D
> RadTicketsFileDownloadForEmailAttachmentBean.getTempFilePath() %>" />
>=20
>=20
>         </c:forEach>
>         </jsp:useBean>
>=20
>=20
>=20
> ... And the error message:
>=20
> org.apache.jasper.JasperException: Unable to compile class for JSP:
>=20
> An error occurred at line: 97 in the jsp file:
> /web/radtickets/ticket_email_response/ticket_email_response_dispatcher_=
page.jsp
> Cannot make a static reference to the non-static method
> getTempFilePath() from the type
> RadTicketsFileDownloadForEmailAttachmentBean
> 94: 	=09
> 95:
> 96: 		<%-- /RadTicketsFileDownloadForEmailAttachment?attachmentId=3D${a=
ll_attachments_for_this_ticket_row.id}&fileName=3D${all_attachments_for_t=
his_ticket_row.attachment_name}
> --%>
> 97: 		<mt:attach type=3D"application/octet-stream"
> 98: 		name=3D"${all_attachments_for_this_ticket_row.attachment_name}"

> 99: 		filename=3D"<%=3D
> RadTicketsFileDownloadForEmailAttachmentBean.getTempFilePath() %>" />
> 100:

So don't make a static reference to the bean:

 RadTicketsFileDownloadForEmailAttachmentBean.getTempFilePath()

 <yourbeanname>.getTempFilePath()


p

Mime
View raw message