You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Ferindo Middleton <fe...@gmail.com> on 2010/09/03 05:49:51 UTC

[email] Dynamic attachments in mailer taglib 2 using JavaBean

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.

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.

I will paste my getter method below, the JSP call to that method and
the error message below: any guidance is welcome. Thank you:

Getter method in jsvabean (javabean compiles fine):

                public String getTempFilePath() {
                    this.downloadedfilename=
tempFilePath;
                    return this.downloadedfilename;

                  }

JSP call to getter method above:

        <jsp:useBean id="getFilePath" scope="request"
        class="hall.RadTicketsFileDownloadForEmailAttachmentBean">
   <jsp:setProperty name="getFilePath"
      property="fileId"
      value="${all_attachments_for_this_ticket_row.id}" />

           <jsp:setProperty name="getFilePath"
      property="originalFileName"
      value="${all_attachments_for_this_ticket_row.attachment_name}" />

        <c:forEach items="${all_attachments_for_this_ticket.rows}"
var="all_attachments_for_this_ticket_row">



        <%-- /RadTicketsFileDownloadForEmailAttachment?attachmentId=${
all_attachments_for_this_ticket_row.id}&fileName=${all_attachments_for_this_ticket_row.attachment_name}
--%>
        <mt:attach type="application/octet-stream"
        name="${all_attachments_for_this_ticket_row.attachment_name}"
        filename="<%=
RadTicketsFileDownloadForEmailAttachmentBean.getTempFilePath() %>" />


        </c:forEach>
        </jsp:useBean>



... And the error message:

org.apache.jasper.JasperException: Unable to compile class for JSP:

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: 		
95:
96: 		<%-- /RadTicketsFileDownloadForEmailAttachment?attachmentId=${all_attachments_for_this_ticket_row.id}&fileName=${all_attachments_for_this_ticket_row.attachment_name}
--%>
97: 		<mt:attach type="application/octet-stream"
98: 		name="${all_attachments_for_this_ticket_row.attachment_name}"
99: 		filename="<%=
RadTicketsFileDownloadForEmailAttachmentBean.getTempFilePath() %>" />
100:


Stacktrace:
	org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
	org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
	org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:312)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:299)
	org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:589)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


Ferindo

Re: [email] Dynamic attachments in mailer taglib 2 using JavaBean

Posted by Pid <pi...@pidster.com>.
On 03/09/2010 14:36, Wesley Acheson wrote:
> No Ferindo. What he's saying is you are calling the class not an instance of
> the class.
> 
> You can only call a class if the method is stactic.
> http://download.oracle.com/javase/tutorial/java/javaOO/classvars.html

        <jsp:useBean id="getFilePath" scope="request"
        class="hall.RadTicketsFileDownloadForEmailAttachmentBean">

http://java.sun.com/products/jsp/tags/11/syntaxref11.fm14.html

You've defined 'getFilePath' as the instance name, so that's what you
need to refer to, rather than the Class name, as Wesley explained.


p

Re: [email] Dynamic attachments in mailer taglib 2 using JavaBean

Posted by Wesley Acheson <we...@gmail.com>.
No Ferindo. What he's saying is you are calling the class not an instance of
the class.

You can only call a class if the method is stactic.
http://download.oracle.com/javase/tutorial/java/javaOO/classvars.html



On Fri, Sep 3, 2010 at 3:32 PM, Ferindo Middleton <
ferindo.middleton@gmail.com> wrote:

> That's what I can't understand. Should my call to the bean be a valid
> non-static code to get that value? I am new to java & javabeans. The
> statement you wrote is exactly my statement in the JSP:
>
> > <yourbeanname>.getTempFilePath()
> Is the same as:
>
> > RadTicketsFileDownloadForEmailAttachmentBean.getTempFilePath()
>
>
> How else do I make this statement in a non-static way?
>
> Ferindo
>
> On Sep 3, 2010, at 7:13 AM, Pid <pi...@pidster.com> wrote:
>
> > 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.
> >>
> >> 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.
> >>
> >> I will paste my getter method below, the JSP call to that method and
> >> the error message below: any guidance is welcome. Thank you:
> >>
> >> Getter method in jsvabean (javabean compiles fine):
> >>
> >>                public String getTempFilePath() {
> >>                    this.downloadedfilename=
> >> tempFilePath;
> >>                    return this.downloadedfilename;
> >>
> >>                  }
> >>
> >> JSP call to getter method above:
> >>
> >>        <jsp:useBean id="getFilePath" scope="request"
> >>        class="hall.RadTicketsFileDownloadForEmailAttachmentBean">
> >>   <jsp:setProperty name="getFilePath"
> >>      property="fileId"
> >>      value="${all_attachments_for_this_ticket_row.id}" />
> >>
> >>           <jsp:setProperty name="getFilePath"
> >>      property="originalFileName"
> >>      value="${all_attachments_for_this_ticket_row.attachment_name}" />
> >>
> >>        <c:forEach items="${all_attachments_for_this_ticket.rows}"
> >> var="all_attachments_for_this_ticket_row">
> >>
> >>
> >>
> >>        <%-- /RadTicketsFileDownloadForEmailAttachment?attachmentId=${
> >> all_attachments_for_this_ticket_row.id
> }&fileName=${all_attachments_for_this_ticket_row.attachment_name}
> >> --%>
> >>        <mt:attach type="application/octet-stream"
> >>        name="${all_attachments_for_this_ticket_row.attachment_name}"
> >>        filename="<%=
> >> RadTicketsFileDownloadForEmailAttachmentBean.getTempFilePath() %>" />
> >>
> >>
> >>        </c:forEach>
> >>        </jsp:useBean>
> >>
> >>
> >>
> >> ... And the error message:
> >>
> >> org.apache.jasper.JasperException: Unable to compile class for JSP:
> >>
> >> 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:
> >> 95:
> >> 96:        <%--
> /RadTicketsFileDownloadForEmailAttachment?attachmentId=${
> all_attachments_for_this_ticket_row.id
> }&fileName=${all_attachments_for_this_ticket_row.attachment_name}
> >> --%>
> >> 97:        <mt:attach type="application/octet-stream"
> >> 98:        name="${all_attachments_for_this_ticket_row.attachment_name}"
> >
> >> 99:        filename="<%=
> >> RadTicketsFileDownloadForEmailAttachmentBean.getTempFilePath() %>" />
> >> 100:
> >
> > So don't make a static reference to the bean:
> >
> > RadTicketsFileDownloadForEmailAttachmentBean.getTempFilePath()
> >
> > <yourbeanname>.getTempFilePath()
> >
> >
> > p
> > <0x62590808.asc>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: [email] Dynamic attachments in mailer taglib 2 using JavaBean

Posted by Ferindo Middleton <fe...@gmail.com>.
That's what I can't understand. Should my call to the bean be a valid
non-static code to get that value? I am new to java & javabeans. The
statement you wrote is exactly my statement in the JSP:

> <yourbeanname>.getTempFilePath()
Is the same as:

> RadTicketsFileDownloadForEmailAttachmentBean.getTempFilePath()


How else do I make this statement in a non-static way?

Ferindo

On Sep 3, 2010, at 7:13 AM, Pid <pi...@pidster.com> wrote:

> 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.
>>
>> 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.
>>
>> I will paste my getter method below, the JSP call to that method and
>> the error message below: any guidance is welcome. Thank you:
>>
>> Getter method in jsvabean (javabean compiles fine):
>>
>>                public String getTempFilePath() {
>>                    this.downloadedfilename=
>> tempFilePath;
>>                    return this.downloadedfilename;
>>
>>                  }
>>
>> JSP call to getter method above:
>>
>>        <jsp:useBean id="getFilePath" scope="request"
>>        class="hall.RadTicketsFileDownloadForEmailAttachmentBean">
>>   <jsp:setProperty name="getFilePath"
>>      property="fileId"
>>      value="${all_attachments_for_this_ticket_row.id}" />
>>
>>           <jsp:setProperty name="getFilePath"
>>      property="originalFileName"
>>      value="${all_attachments_for_this_ticket_row.attachment_name}" />
>>
>>        <c:forEach items="${all_attachments_for_this_ticket.rows}"
>> var="all_attachments_for_this_ticket_row">
>>
>>
>>
>>        <%-- /RadTicketsFileDownloadForEmailAttachment?attachmentId=${
>> all_attachments_for_this_ticket_row.id}&fileName=${all_attachments_for_this_ticket_row.attachment_name}
>> --%>
>>        <mt:attach type="application/octet-stream"
>>        name="${all_attachments_for_this_ticket_row.attachment_name}"
>>        filename="<%=
>> RadTicketsFileDownloadForEmailAttachmentBean.getTempFilePath() %>" />
>>
>>
>>        </c:forEach>
>>        </jsp:useBean>
>>
>>
>>
>> ... And the error message:
>>
>> org.apache.jasper.JasperException: Unable to compile class for JSP:
>>
>> 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:
>> 95:
>> 96:        <%-- /RadTicketsFileDownloadForEmailAttachment?attachmentId=${all_attachments_for_this_ticket_row.id}&fileName=${all_attachments_for_this_ticket_row.attachment_name}
>> --%>
>> 97:        <mt:attach type="application/octet-stream"
>> 98:        name="${all_attachments_for_this_ticket_row.attachment_name}"
>
>> 99:        filename="<%=
>> RadTicketsFileDownloadForEmailAttachmentBean.getTempFilePath() %>" />
>> 100:
>
> So don't make a static reference to the bean:
>
> RadTicketsFileDownloadForEmailAttachmentBean.getTempFilePath()
>
> <yourbeanname>.getTempFilePath()
>
>
> p
> <0x62590808.asc>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: [email] Dynamic attachments in mailer taglib 2 using JavaBean

Posted by Pid <pi...@pidster.com>.
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.
> 
> 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.
> 
> I will paste my getter method below, the JSP call to that method and
> the error message below: any guidance is welcome. Thank you:
> 
> Getter method in jsvabean (javabean compiles fine):
> 
>                 public String getTempFilePath() {
>                     this.downloadedfilename=
> tempFilePath;
>                     return this.downloadedfilename;
> 
>                   }
> 
> JSP call to getter method above:
> 
>         <jsp:useBean id="getFilePath" scope="request"
>         class="hall.RadTicketsFileDownloadForEmailAttachmentBean">
>    <jsp:setProperty name="getFilePath"
>       property="fileId"
>       value="${all_attachments_for_this_ticket_row.id}" />
> 
>            <jsp:setProperty name="getFilePath"
>       property="originalFileName"
>       value="${all_attachments_for_this_ticket_row.attachment_name}" />
> 
>         <c:forEach items="${all_attachments_for_this_ticket.rows}"
> var="all_attachments_for_this_ticket_row">
> 
> 
> 
>         <%-- /RadTicketsFileDownloadForEmailAttachment?attachmentId=${
> all_attachments_for_this_ticket_row.id}&fileName=${all_attachments_for_this_ticket_row.attachment_name}
> --%>
>         <mt:attach type="application/octet-stream"
>         name="${all_attachments_for_this_ticket_row.attachment_name}"
>         filename="<%=
> RadTicketsFileDownloadForEmailAttachmentBean.getTempFilePath() %>" />
> 
> 
>         </c:forEach>
>         </jsp:useBean>
> 
> 
> 
> ... And the error message:
> 
> org.apache.jasper.JasperException: Unable to compile class for JSP:
> 
> 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: 		
> 95:
> 96: 		<%-- /RadTicketsFileDownloadForEmailAttachment?attachmentId=${all_attachments_for_this_ticket_row.id}&fileName=${all_attachments_for_this_ticket_row.attachment_name}
> --%>
> 97: 		<mt:attach type="application/octet-stream"
> 98: 		name="${all_attachments_for_this_ticket_row.attachment_name}"

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

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

 RadTicketsFileDownloadForEmailAttachmentBean.getTempFilePath()

 <yourbeanname>.getTempFilePath()


p