Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Excel spread sheet (in JSP) display issues

 
Mike Broad
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
subject: Excel spread sheet (in JSP) specific name display issues

Environment: Java, J2EE, MyEclipse, Oracle WebShpere ,Struts framwork

I have few reports and clicking the report executes an action and displays the corresponding report (Action forward).

Before displaying the report it pops up a window (with save/open/cancel buttons). Now the widnow has same name for all the reports (load-reports.xls).
I need to display a specific report name.
I searched the work sapce and ould not find any clue.
Any help will be appreciated, TIA
Mike
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look up the Content-Disposition response header.
There is sample code that sets this in our JspAndExcel FAQ entry.
There is a link to the JspFaq at the top of this forum.
 
Mike Broad
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you a lot Ben.
I appreciate your help.
This code in my jsp works fine, has there been only one custom name to display:

<%@ page contentType="application/vnd.ms-excel" autoFlush="true" %>
<% response.setHeader("Content-Disposition", "attachment; filename=\"EmployeeReport.xls\""); %>

But still I am not able to figure out completely.
I know the logic , but need some help.

I have nearly 10 reports and I need to use <c:if ...> tag in my Jsp and display the right report name ( on the Excel file)
Can you pl help me how I can do it in my report.jsp .


// In the ReportAction.execute(.....) method
//I have set the report name as an attribute
....
Report report = new Report ();
String r_name = report. getName(); // EmployeeReport, ?ManagerReport etc

System.out.println ("\n\n rep...name: " + s_r_name + "\n") ;
//outputs the expected name to console
req.setAttribute("reportName", r_name );

I need to retrieve it in jsp and add logic to display specific report name such as EmployeeReport, MangerReport etc

Currently my jsp file has these 6 lines of code code:

<%@ taglib uri="/WEB-INF/rep.tld" prefix="rep" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<%@ page import="com.xyz.report.Report" %>

<%@ page contentType="application/vnd.ms-excel" autoFlush="true" %>
<% response.setHeader("Content-Disposition", "attachment; filename=\"EmployeeReport.xls\""); %>
<rep:displayReport/>

Thanks,
Mike
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic