File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes Problem: nothing works in jsp after downloading Excel.    Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Problem: nothing works in jsp after downloading Excel.    " Watch "Problem: nothing works in jsp after downloading Excel.    " New topic

Problem: nothing works in jsp after downloading Excel.

Priyanka mittal

Joined: Jan 06, 2010
Posts: 1
I have a "search.jsp" with a commandButton to generate excel. "Report.jsp" opens up in a new window when i click on this button by running below mentioned javascript. I can download Excel successfully by clicking on Download Excel link in report,jsp. Problem is, once i close this new window, I am unable to perform any other action in "search.jsp" even if i do not perform download. If i click on any other button or link "search.jsp", it replaces whole jsp with the Downlaod Excel link. and nothing happens after that . i need to close the seesion and start all over again from login page. Does anyone has solution. It will be big help. Thanks.


function aaaa()
mywindow'report.jsf', 'popupWindow', 'width=400,height=200,left=0,top=100,screenX=0,screenY=100');

Following is report.jsp:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<%@ taglib uri="" prefix="f" %>
<%@ taglib uri="" prefix="h"%>
<%@ taglib uri="" prefix="bjsf" %>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<h:commandLink actionListener="#{searchpage.export}" value="Download Excel" />
<a href="javascript:window.close();return false;">cancel</a>

Following is export function which runs when i click on above commandlink "Download Excel":

public void export(ActionEvent event) {
try {
FacesContext context = FacesContext.getCurrentInstance();
HttpServletResponse response = (HttpServletResponse) context
"attachment; filename=report.xls");
ServletOutputStream servletOutputStream = response
WritableWorkbook workbook = Workbook
WritableSheet sheet = workbook.createSheet("First Sheet", 0);
WritableFont lfont = new WritableFont(WritableFont.ARIAL, 10);
WritableCellFormat lformat = new WritableCellFormat(lfont);
lformat.setBorder(Border.ALL, BorderLineStyle.THICK);
WritableFont rfont = new WritableFont(WritableFont.ARIAL, 10);
WritableCellFormat rformat = new WritableCellFormat(rfont);
rformat.setBorder(Border.ALL, BorderLineStyle.THIN);
for (int i = 0; i < this.list.size(); i++) {
HashMap h = (HashMap) this.list.get(i);
if (i == 0) {
Set s = (Set) h.keySet();
Iterator itr = s.iterator();
int j = 1;
while (itr.hasNext()) {
Label label2 = new Label(j, 1,,
Collection c = h.values();
Iterator itr = c.iterator();
int j = 1;
while (itr.hasNext()) {
Label label2 = new Label(j, (i 2),,

} catch (Exception e) {
I agree. Here's the link:
subject: Problem: nothing works in jsp after downloading Excel.
It's not a secret anymore!