Package appointmanager;
Import javax. servlet .*;
Import javax. servlet. http .*;
Import java. Io .*;
Import java. util .*;
// Import net. SF. jasperreports. Engine. *; //. Jasper. Engine .*;
Import net. SF. jasperreports. Engine. jrexception;
Import net. SF. jasperreports. Engine. jrruntimeexception;
Import net. SF. jasperreports. Engine. jasperfillmanager;
Import net. SF. jasperreports. Engine. jasperprint;
Import net. SF. jasperreports. Engine. jasperrunmanager;
Import util .*;
Import java. SQL .*;
/**
* <P> title: lims B/S </P>
* <P> Description: lims B/S revision </P>
* <P> copyright: Copyright (c) 2004 </P>
* <P> company: labtech </P>
* @ Author Xiong qinxue
* @ Version 1.1
*/
Public class getappointreport extends httpservlet {
Private Static final string content_type = "text/html; charset = gb2312 ";
// Initialize global variables
Public void Init () throws servletexception {
}
// Process the http get request
Public void doget (httpservletrequest request, httpservletresponse response) throws servletexception, ioexception {
String id = request. getparameter ("ID ");
If (ID = NULL ){
Id = "";
}
Try {
Dbutils datasource = new dbutils ();
Connection conn = datasource. conn_odbc ();
Servletcontext = This. getservletcontext ();
// File reportfile = new file (servletcontext. getrealpath ("/WEB-INF/classes/report/testcontract. Jasper"); // newappoint. Jasper
File reportfile = new file (servletcontext. getrealpath ("/WEB-INF/classes/report/appointinfo. Jasper "));
If (! Reportfile. exists ())
Throw new jrruntimeexception ("file datasourcetest. Jasper not found. The report design must be compiled first .");
Map parameters = new hashmap ();
// Parameters. Put ("wtbh", ID); // set parameters for the report
Parameters. Put ("ID", ID );
Byte [] bytes = jasperrunmanager. runreporttopdf (reportfile. getpath (), parameters, Conn );
System. Out. println ("ID =" + ID + ";" + reportfile. getpath ());
Response. setcontenttype ("application/pdf ");
Response. setcontentlength (bytes. Length );
Servletoutputstream ouputstream = response. getoutputstream ();
Ouputstream. Write (bytes, 0, bytes. Length );
Ouputstream. Flush ();
Ouputstream. Close ();
}
Catch (exception e ){
Response. setcontenttype (content_type );
Printwriter out = response. getwriter ();
Out. Print (E. getmessage ());
}
}
// Process the http post request
Public void dopost (httpservletrequest request, httpservletresponse response) throws servletexception, ioexception {
Doget (request, response );
}
// Clean up resources
Public void destroy (){
}
}