Hello,
I'm having trouble reloading/refreshing my main window after a submit. My main window is an input form in which i ask for a start and end date to show a log report. When the user click submit it then displays a separate window with PDF format displaying the log info. I use this section of code to display my PDF.
byte[] output = report.displayReport();
try
{
response.setContentLength(output.length);
response.setContentType("application/pdf");
OutputStream os = response.getOutputStream();
os.write(output);
os.flush();
os.close();
}catch (IOException e) {
e.printStackTrace();
return mapping.findForward("reload");
This code is included in my action class. return mapping.findForward("reload"); <--- this line is never reached since when I run the above code the PDF is open in a new window and I lose focus on my main window so this line "return mapping.findForward("reload")" is no longer effective. Therefore when the new window appears with the PDF info, my main window still shows the processing page with the hour glass and won't go back to the input form.
If I take teh PDF section out then the hour glass goes away after it finish processing and the input form is reloaded. I tried putting that pdf section above directly into my JSP as Javascript function then use <%%> to place the code in between but then my JSP page show up blank
Any feed backs on how I can get focus back to the main window to refresh it and to display the input form rather then the hour glass processing image after the PDF pop up, would be much appreciated.
================My Action Class code==========
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception
{
System.out.println("LogReportCriteriaAction");
LogReportCriteriaForm logReportForm = (LogReportCriteriaForm) form;
String startDate = logReportForm.getStartDate();
String endDate = logReportForm.getEndDate();
String sMonth =startDate.substring(startDate.indexOf("-")+1,startDate.lastIndexOf("-"));
String eMonth =endDate.substring(endDate.indexOf("-")+1,endDate.lastIndexOf("-"));
//Converting to number months
for(int i=0; i<MONTHS_LIST.length;i++){
if (sMonth.equalsIgnoreCase(MONTHS_LIST)) sMonth = i+1+"";
if (eMonth.equalsIgnoreCase(MONTHS_LIST)) eMonth = i+1+"";
}
startDate = startDate.substring(startDate.lastIndexOf("-")+1,startDate.length()) +"-"+ sMonth +"-"+ startDate.substring(0,startDate.indexOf("-"));
endDate = endDate.substring(endDate.lastIndexOf("-")+1,endDate.length()) +"-"+ eMonth +"-"+ endDate.substring(0,endDate.indexOf("-"));
LogReportCriteria reportBean = new LogReportCriteria(Date.valueOf(startDate),Date.valueOf(endDate));
LogReporter report = new LogReporter(reportBean);
byte[] output = report.displayReport();
response.setContentLength(output.length);
response.setContentType("application/pdf");
request.getSession().setAttribute("pdfOutput",report.displayReport());
request.getSession().setAttribute("pdfOutputResponse",response);
//byte[] output = (byte[])request.getSession().getAttribute("pdfOutput");
try
{
response.setContentLength(output.length);
response.setContentType("application/pdf");
OutputStream os = response.getOutputStream();
os.write(output);
os.flush();
os.close();
}catch (IOException e) {
e.printStackTrace();
System.out.println("PDF output error: " + e);
}
System.out.println("PDF finished processing");
return mapping.findForward("reload");
}
===================================================
Anh
I'm having trouble reloading/refreshing my main window after a submit. My main window is an input form in which i ask for a start and end date to show a log report. When the user click submit it then displays a separate window with PDF format displaying the log info. I use this section of code to display my PDF.
byte[] output = report.displayReport();
try
{
response.setContentLength(output.length);
response.setContentType("application/pdf");
OutputStream os = response.getOutputStream();
os.write(output);
os.flush();
os.close();
}catch (IOException e) {
e.printStackTrace();
return mapping.findForward("reload");
This code is included in my action class. return mapping.findForward("reload"); <--- this line is never reached since when I run the above code the PDF is open in a new window and I lose focus on my main window so this line "return mapping.findForward("reload")" is no longer effective. Therefore when the new window appears with the PDF info, my main window still shows the processing page with the hour glass and won't go back to the input form.
If I take teh PDF section out then the hour glass goes away after it finish processing and the input form is reloaded. I tried putting that pdf section above directly into my JSP as Javascript function then use <%%> to place the code in between but then my JSP page show up blank
Any feed backs on how I can get focus back to the main window to refresh it and to display the input form rather then the hour glass processing image after the PDF pop up, would be much appreciated.
================My Action Class code==========
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception
{
System.out.println("LogReportCriteriaAction");
LogReportCriteriaForm logReportForm = (LogReportCriteriaForm) form;
String startDate = logReportForm.getStartDate();
String endDate = logReportForm.getEndDate();
String sMonth =startDate.substring(startDate.indexOf("-")+1,startDate.lastIndexOf("-"));
String eMonth =endDate.substring(endDate.indexOf("-")+1,endDate.lastIndexOf("-"));
//Converting to number months
for(int i=0; i<MONTHS_LIST.length;i++){
if (sMonth.equalsIgnoreCase(MONTHS_LIST)) sMonth = i+1+"";
if (eMonth.equalsIgnoreCase(MONTHS_LIST)) eMonth = i+1+"";
}
startDate = startDate.substring(startDate.lastIndexOf("-")+1,startDate.length()) +"-"+ sMonth +"-"+ startDate.substring(0,startDate.indexOf("-"));
endDate = endDate.substring(endDate.lastIndexOf("-")+1,endDate.length()) +"-"+ eMonth +"-"+ endDate.substring(0,endDate.indexOf("-"));
LogReportCriteria reportBean = new LogReportCriteria(Date.valueOf(startDate),Date.valueOf(endDate));
LogReporter report = new LogReporter(reportBean);
byte[] output = report.displayReport();
response.setContentLength(output.length);
response.setContentType("application/pdf");
request.getSession().setAttribute("pdfOutput",report.displayReport());
request.getSession().setAttribute("pdfOutputResponse",response);
//byte[] output = (byte[])request.getSession().getAttribute("pdfOutput");
try
{
response.setContentLength(output.length);
response.setContentType("application/pdf");
OutputStream os = response.getOutputStream();
os.write(output);
os.flush();
os.close();
}catch (IOException e) {
e.printStackTrace();
System.out.println("PDF output error: " + e);
}
System.out.println("PDF finished processing");
return mapping.findForward("reload");
}
===================================================
Anh