iReportが印刷プレビューを表示する問題について.
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// .jasper
String type=request.getParameter("type");
String grade=request.getParameter("grade");
String class_1= request.getParameter("class");
String sql="select * from print where type='"+type+"'";
if(!grade.equals("")){
sql=sql+" and grade='"+grade+"'";
}
if(!class_1.equals("")){
sql=sql+" and class='"+grade+class_1+"'";
}
System.out.println(sql);
String path="";
if(type.equals(" ") || type.equals(" ")){
path="print_x";
}
if(type.equals(" ") || type.equals(" ")){
path="print_xx";
}
if(type.equals(" ")){
path="print_xxx";
}
if(type.equals(" ")){
path="print_xxxx";
}
String u="/print/"+path;
System.out.println(u);
//String u="/print/print_x.jasper";
File reportFile = new File(this.getServletContext().getRealPath(u));
String url="jdbc:mysql://localhost:3306/jmzc";
try{
Class.forName("com.mysql.jdbc.Driver");
Map parameters = new HashMap();
//parameters.put("SQLSTR",sql); //"SQLSTR" , String
Connection conn = DriverManager.getConnection(url,"root", "seebig");
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery(sql);
String pp=this.getServletContext().getRealPath(u);
System.out.println(pp);
JasperFillManager.fillReportToFile(pp+".jasper",parameters,new JRResultSetDataSource(rs));
JRViewer jr = new JRViewer(pp+".jrprint",false);
JFrame jf = new JFrame(type);
jf.add(jr);
jf.pack();
jf.setSize(1024, 600);
jf.setVisible(true);
}catch(Exception ex){
ex.printStackTrace();
}
}
このservletでは、iReportのJRViewerを使って印刷プレビューを作成しています.クライアントのパソコンでページの印刷プレビューをクリックすると、何の表示もありません.サービス側を振り返ると、JRViewerの印刷プレビューを表示するプログラムがあります.なぜですか.