2
EclipseでのCrystal Reportの問題に直面しています。JavaでのCrystal Report DB認証
は、私のような応答にビューアオブジェクトを書き込むことにより、Crystalレポートビューアをレンダリングするために、サーブレットを使用しています:
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);
}
}
私はそれが行く、それはその後、JDBCログインページに私をリダイレクトするこのサーブレットを要求しようとしていますこのサーブレットに戻ります。私はどこかにハードコードすることによってjdbcログインステップを避ける必要があります。私を助けてください、すべての単一のコメントが評価されます。
私はそれが本当に遅れている知っているが、私は1つのコードを維持するために持っています古いコードのあなたができるなら私を助けてください。 'reportClientDocument.getDatabaseController()。logon(db_username、db_password);'。私がここで与えている資格情報は問題ではありません。レポートはブラウザで表示されたときに資格情報を要求します。追加情報が必要であり、データベースのユーザー名、パスワードを尋ねます。ユーザー名を入力すると、パスワードが機能します。視聴者のためにブラウザにユーザ名とパスワードを入力しないようにするにはどうすればいいですか?私はこれで一日を過ごした、Googleは本当に助けになっていない – developernaren