Dear All, I'm facing a problem in Crystal Report with Eclipse.
I am using a servlet to render the crystal report viewer by writing the viewer object to the response like:
public class ReportViewer extends HttpServlet {
@SuppressWarnings("deprecation")
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try {
String reportName = "WEB-INF/includes/reports/"+request.getParameter("ReportName");
ReportClientDocument clientDoc = (ReportClientDocument) request.getSession().getAttribute(reportName);
if (clientDoc == null) {
// Report can be opened from the relative location specified in the CRConfig.xml, or the report location
// tag can be removed to open the reports as Java resources or using an absolute path
// (absolute path not recommended for Web applications).
clientDoc = new ReportClientDocument();
// Open report
clientDoc.open(reportName, OpenReportOptions._discardSavedData);
// Store the report document in session
ConnectionInfo info = new ConnectionInfo();
info.setUserName("sa");
info.setPassword("sa");
Tables t = clientDoc.getDatabaseController().getDatabase().getTables();
for (com.crystaldecisions.sdk.occa.report.data.ITable table : t) {
IConnectionInfo Ic = table.getConnectionInfo();
Ic.setPassword("sa");
Ic.setUserName("sa");
table.setConnectionInfo(Ic);
}
request.getSession().setAttribute(reportName, clientDoc);
}
// Create the CrystalReportViewer object
CrystalReportViewer crystalReportPageViewer = new CrystalReportViewer();
// set the reportsource property of the viewer
IReportSource reportSource = clientDoc.getReportSource();
crystalReportPageViewer.setReportSource(reportSource);
// set viewer attributes
crystalReportPageViewer.setOwnPage(true);
crystalReportPageViewer.setOwnForm(true);
// Apply the viewer preference attributes
// Process the report
crystalReportPageViewer.processHttpRequest(request, response, request.getSession(false).getServletContext(), null);
} catch (ReportSDKExceptionBase e) {
System.out.println(e);
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
}
When I am trying to request this servlet it redirects me to jdbc login page then it goes back to this servlet. I need to avoid jdbc login step by hardcoding it somewhere. please help me, every single comment will be appreciated.