display tag

Hello,

       I want to understand why an export filter is needed for a display tag to function properly !! How does display tag export the content of a table to pdf or excel and during this process why does it need to have a filter (export filter) ??

      when we are trying to export does the request go back to server and get the information again ??

Thank you.
letsbedecentAsked:
Who is Participating?
 
bloodredsunCommented:
>> so, if the response buffer is not flushed how can the data be displayed on the page ??

That's for each individual request. Once the request has beenc ompletely processed is it written out to the browser.

>>because only once the data is displayed on page will the user want to export it to a pdf or xls format... by clicking on one of the options right !!

Yes. In that case, the data is retrieved again but this time it is formatted into pdf or xls (or whatever format they have clicked on) and then this is sent to the user. All my comments above are only relevent to a single request. Unless you have cached the data somewhere (e.g. in the session), the data will be requested again for each request (but only once per request).

How are you generating the other files (pdf,  xls)?
0
 
bloodredsunCommented:
Could you be a little more specific please? If you can give some examples of the code then maybe the experts here can try and help as what you've described is a bit too general to help on.

The only thing I can guess at is that you are using a filter to add the mime-type of the downloaded document. In Java you would use XSL-FO and HSSF(POI) to create pdfs and xls files on the fly, so maybe this is what is being done, or else somehting a little more involved like Actuate.

>>when we are trying to export does the request go back to server and get the information again ??
No idea unless you can provide some code, like what display tag and what filter
0
 
bloodredsunCommented:
Ah, I've just found this displaytag.sourceforge.net which I assume is what you are talking about as it has both dispay tags and an export filter.

In answer to your question, the filter disallows the response to be flushed, This means that you can reset the content-type (mime-type) of any binary content like pdf/xls files even though you may have already written to the response. This applies to any non-html format data and to binary data.

It doesn't go and get the data again, all it does it prevent the response buffer from being flushed, so that the display tag can work in more situations than it would be able to do otherwise.
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
bloodredsunCommented:
Other causes of the buffer being flushed:

The method out.flush() has been called.
A file has been included, e.g. <jsp:include page="header.jsp" flush="true"/>
You have filled the buffer up, e.g. the jsp has outputted more characters than the page buffer can hold.

Also, be aware that simply writing to the output using out.println() or <%=blah%> will commit the response whcih means that trying to change a response property like the content-type would throw an exception.

Any of these would cause the display tag to fail unless you use the export filter.
0
 
letsbedecentAuthor Commented:
so, if the response buffer is not flushed how can the data be displayed on the page ??

because only once the data is displayed on page will the user want to export it to a pdf or xls format... by clicking on one of the options right !!
0
 
letsbedecentAuthor Commented:
>>How are you generating the other files(pdf, xls)?

Well, i am not doing anything except using the tag... i got a sample code.  In that there is simply an option for export (to 4 standard types, Comma seperated list, pdf, xls, xml) at the bottom of the table,

You simply click on them and the file-download dialog opens up asking you if you want to save it or open it !!!!!  

I just am not able to understand how the display tag does all of this !!
0
 
bloodredsunCommented:
I'm guessing (as I've not seent the code) that all it does is allow to to change the response header even if the response has been commited.

If you look at the HTML underneath the export buttons, I think it would say somehting like

/download.jsp?type=pdf
/download.jsp?type=csv

And the content type will be taken from the parameter (or somewhere else in the name). Also. it may set the atttachment header so that the save file box automatically pops up.
0
 
bloodredsunCommented:
As you saw earlier with the question about:
response.setHeader("Content-Disposition","attachment; filename=\"" + attachmentVO.getFileName() + "\"");
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.