Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


display tag

Posted on 2005-04-25
Medium Priority
Last Modified: 2012-05-05

       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.
Question by:letsbedecent
  • 6
  • 2
LVL 29

Expert Comment

ID: 13859232
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
LVL 29

Expert Comment

ID: 13859343
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.
LVL 29

Expert Comment

ID: 13859482
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.
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.


Author Comment

ID: 13859510
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 !!
LVL 29

Accepted Solution

bloodredsun earned 1500 total points
ID: 13859609
>> 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)?

Author Comment

ID: 13859642
>>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 !!
LVL 29

Expert Comment

ID: 13860093
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


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.
LVL 29

Expert Comment

ID: 13860101
As you saw earlier with the question about:
response.setHeader("Content-Disposition","attachment; filename=\"" + attachmentVO.getFileName() + "\"");

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Dropbox has a relatively new feature called Smart Sync.  This feature allows Dropbox Professional (not plus) and Dropbox Business (if enabled) users to store information in Dropbox WITHOUT storing any files on their computer.
Herein one will find an aggregate of some of my experience building and deploying virtualization stacks both in standalone, clustered Hyper-V, clustered Hyper-V with a Scale-Out File Server (SOFS) backend, and Storage Spaces Direct (S2D).
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Suggested Courses
Course of the Month12 days, 7 hours left to enroll

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question