Hi,
I have been trying to export my reports to PDF using Crystal Enterprise Java SDK.
When I do this using JSP it works fine, but when I try to do this using a Servlet it gives me "The Response has been Commited" error. and the path of the Viewer on the Browser.
Can anybody help ?
I am pasting the code for servlet
/**********************************************************/
/** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
* @param response servlet response
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, java.io.IOException {
ServletContext application = this.getServletContext();
ServletConfig config = this.getServletConfig();
HttpSession session = request.getSession();
response.setContentType("text/html;charset=ISO-8859-1");
PrintWriter out = response.getWriter();
try{
// Connect to Crystal Enterprise
CrystalEnterprise ce = new CrystalEnterprise();
ISessionMgr sm = ce.getSessionMgr();
IEnterpriseSession es = sm.logon(mUser, mPassword, mAPSName, mAuthType);
// Get the Report Application Factory service from Crystal Enterprise
IReportAppFactory rptAppFactory = (IReportAppFactory)es.getService("", "RASReportService");
// Get the InfoStore service from Crystal Enterprise
IInfoStore infoStore = (IInfoStore)es.getService("", "InfoStore");
// Retrieve the report by name from Crystal Enterprise
IInfoObjects oInfoObjects = infoStore.query("Select SI_ID From CI_INFOOBJECTS Where SI_NAME = '" + "phonelist" + "'");
// Open the report into a Report Document object
ReportClientDocument clientDoc = rptAppFactory.openDocument((IInfoObject)oInfoObjects.get(0), 0, Locale.ENGLISH);
// Create a Viewer object
CrystalReportViewer viewer = new CrystalReportViewer();
// Set the name for the viewer
viewer.setName("Crystal_Report_Viewer");
// Set the source for the viewer to the client documents report source
viewer.setReportSource(clientDoc.getReportSource());
viewer.setOwnPage(true);
viewer.setDisplayToolbar(true);
// Process the http request to view the report
viewer.processHttpRequest(request, response, getServletConfig().getServletContext(), out);
// Dispose of the viewer object
viewer.dispose();
}catch(Exception e){
out.println(e.getMessage());
}
}
/** Handles the HTTP <code>POST</code> method.
* @param request servlet request
* @param response servlet response
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, java.io.IOException {
processRequest(request, response);
}
/********************************************************/
I have been trying to export my reports to PDF using Crystal Enterprise Java SDK.
When I do this using JSP it works fine, but when I try to do this using a Servlet it gives me "The Response has been Commited" error. and the path of the Viewer on the Browser.
Can anybody help ?
I am pasting the code for servlet
/**********************************************************/
/** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
* @param response servlet response
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, java.io.IOException {
ServletContext application = this.getServletContext();
ServletConfig config = this.getServletConfig();
HttpSession session = request.getSession();
response.setContentType("text/html;charset=ISO-8859-1");
PrintWriter out = response.getWriter();
try{
// Connect to Crystal Enterprise
CrystalEnterprise ce = new CrystalEnterprise();
ISessionMgr sm = ce.getSessionMgr();
IEnterpriseSession es = sm.logon(mUser, mPassword, mAPSName, mAuthType);
// Get the Report Application Factory service from Crystal Enterprise
IReportAppFactory rptAppFactory = (IReportAppFactory)es.getService("", "RASReportService");
// Get the InfoStore service from Crystal Enterprise
IInfoStore infoStore = (IInfoStore)es.getService("", "InfoStore");
// Retrieve the report by name from Crystal Enterprise
IInfoObjects oInfoObjects = infoStore.query("Select SI_ID From CI_INFOOBJECTS Where SI_NAME = '" + "phonelist" + "'");
// Open the report into a Report Document object
ReportClientDocument clientDoc = rptAppFactory.openDocument((IInfoObject)oInfoObjects.get(0), 0, Locale.ENGLISH);
// Create a Viewer object
CrystalReportViewer viewer = new CrystalReportViewer();
// Set the name for the viewer
viewer.setName("Crystal_Report_Viewer");
// Set the source for the viewer to the client documents report source
viewer.setReportSource(clientDoc.getReportSource());
viewer.setOwnPage(true);
viewer.setDisplayToolbar(true);
// Process the http request to view the report
viewer.processHttpRequest(request, response, getServletConfig().getServletContext(), out);
// Dispose of the viewer object
viewer.dispose();
}catch(Exception e){
out.println(e.getMessage());
}
}
/** Handles the HTTP <code>POST</code> method.
* @param request servlet request
* @param response servlet response
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, java.io.IOException {
processRequest(request, response);
}
/********************************************************/