Link to home
Start Free TrialLog in
Avatar of royalcyber
royalcyber

asked on

Having problem in exporting data while using "Display Tag" from sourceforge.net

Hi I am trying to use display tag in my JSP file. The tag shows the data perfectly fine. But when I click on the export options to export the data in excel or pdf it opens the appropriate application but no data is transferred. I have also included the filter in my web.xml file but still it is not working.
Avatar of borislavmarkov
borislavmarkov

specify the header field Content-Length.
Sometimes Internet Explorer makes the query to your URL twice, take any actions if you depend on that.

Your servlet that returns data should look like:

ServletContext ctx = this.getServletContext();
mime = ctx.getMimeType(fileName);
aResponse.setContentType(mime);
OutputStream out = aResponse.getOutputStream();
aResponse.setContentLength( (int)lengthOfFile );
aResponse.setHeader("Pragma", "no-cache"); //HTTP 1.0
aResponse.setDateHeader("Expires", 1); //prevents caching at the proxy server
aResponse.setHeader("Cache-Control", "max-age=0");

//WRITE DATA
out.write(buf,0,bytes);
....

out.flush();
Avatar of royalcyber

ASKER

I am actually using pre-made "display tag" from sourceforge.net.
I insatalled the .jar files and .tld files as needed and am just passing an arraylist to these tag in JSP and they display
the daata in a table and give options such as sorting or export data to excel, xml etc.

I am not sure how to check teh code for this tag

Please help
ASKER CERTIFIED SOLUTION
Avatar of Siva Prasanna Kumar
Siva Prasanna Kumar
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Anyway what is the URL on this link that is problematic, can you copy paste it so we can analyze it?