I actually had created the same from the sample code from crystal report official page, but the parameter passed into CR did not take any effect that changes the outcome.... here the partial from my jsp code:
String userName = "";
String passWord = "";
String path = "/Report3.rpt";
Fields fields = new Fields();
ParameterField pfield1 = new ParameterField();
Values vals1 = new Values();
ParameterFieldDiscreteValue pfieldDV1 = new ParameterFieldDiscreteValue();
pfield1.setName("SortOrder");
pfieldDV1.setValue("C");
vals1.add(pfieldDV1);
pfield1.setCurrentValues(vals1);
fields.add(pfield1);
IReportSourceFactory2 rsf = new JPEReportSourceFactory();
IReportSource rptSource = (IReportSource)rsf.createReportSource(path,request .getLocale());
CrystalReportViewer viewer = new CrystalReportViewer();
/*create the connection infos object and set the user name and password
to the report*/
ConnectionInfos connInfos = new ConnectionInfos();
IConnectionInfo connInfo1 = new ConnectionInfo();
connInfo1.setUserName(userName);
connInfo1.setPassword(passWord);
//add the IConnectionInfo object into the ConnectionInfo collection
connInfos.add(connInfo1);
//set the connectioninfo into the viewer
viewer.setEnableLogonPrompt(false);
viewer.setDatabaseLogonInfos(connInfos);
viewer.setReportSource(rptSource);
viewer.setParameterFields(fields);
viewer.setEnableParameterPrompt(true);
if (session.getAttribute("refreshed") == null)
{
viewer.refresh();
session.setAttribute("refreshed", "true");
}
viewer.processHttpRequest(request, response,getServletConfig().getServletContext(), out);
viewer.dispose();
|