Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem while Exporting

Status
Not open for further replies.

Leo17

Programmer
Joined
Apr 14, 2004
Messages
6
Location
HK
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);
}

/********************************************************/
 
Hi,

don't know if you are still working on this problem as your post is quite old but the first step I would try is to put a null onto your process http request line ie: viewer.processHttpRequest(request, response, getServletConfig().getServletContext(), null);

If that doesnt work and you are still stuck then email me and I will send you a copy of a working servlet that I received from a crystal expert.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top