Hi,
I need to save the pdf file with default name which generated by
dinamically.
this is the code i am trying to save by default
protected void processRequest (HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
OutputStream bos = response.getOutputStream ();
// this returns pdf byte array
byte ios[] = callReport ( reportId_param , fullyQualifiedReportClassName , paramHashMap ) ;
response.setContentType ("application/pdf");
// reportId_param and reportName_param supplied from some where
String docName = reportId_param + "_" + reportName_param ;
if( fromDate_req != null && toDate_req != null )
{
String dateStr = fromDate_req + "_to_" + toDate_req ;
dateStr = dateStr.replaceAll ( "/" , "_" ) ;
docName = docName + "_" + dateStr ;
}
// here docName would be like "RP_COM_COLL_01_Message_Details_03_09_2008_to_03_09_2008"
response.setHeader ("Content-Disposition","inline; filename=" + docName ) ;
bos.write (ios);
bos.flush ();
}
the above code produces pdf in browser when calling this URL
http://localhost:8080/DAD01TN0801027/RWReportServlet
In browser we can save this PDF by using two ways
1. File -> Save As
2. By using Save Icon within the PDF toolBar
both the actions uses the file name "RWReportServlet" as default instead of using docName
Can any one help me please
Regards
Sakthivel.