archimede76 Posted March 31, 2009 Share Posted March 31, 2009 Hi all!My JSP Web application include simply report without subreport, and other report with subreport, all developed in Jasper Report with IReport tool. All simply report work perfectly in local and in remote, the other report (with subreport) work perfectly in local (see attach 1_right_local) but wrong in my remote server (see attach 2_wrong_remote). Why?(very thank all! I send the 2 attach file and the servlet of pdf opening; but i think the problem is not cause from this servlet. I thik, depending another properties or setting in IReport).ArchimedeCode:package servletReport;import java.io.IOException;import java.sql.Connection;import java.sql.SQLException;import java.util.HashMap;import java.util.Map;import javax.servlet.ServletContext;import javax.servlet.ServletException;import javax.servlet.ServletOutputStream;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import net.sf.jasperreports.engine.JRException;import net.sf.jasperreports.engine.JasperExportManager;import net.sf.jasperreports.engine.JasperFillManager;import net.sf.jasperreports.engine.JasperPrint;import dao.DAOMain;/** * Servlet implementation class for Servlet: ServletReportStreamPDF * */ public class ServletReportStreamPDF extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet { static final long serialVersionUID = 1L; /* (non-Java-doc) * @see javax.servlet.http.HttpServlet#HttpServlet() */ public ServletReportStreamPDF() { super(); } /* (non-Java-doc) * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub String rptFileName = request.getParameter("rptFileName").toString(); String rptFolder = "report"; JasperPrint jp = null; ServletContext context = this.getServletContext(); String mainid = ""; String secid = ""; String subpath = ""; String mainstring = ""; if (request.getParameter("mainid") == null){ mainid = "0"; } else { if (request.getParameter("mainid") != null){ mainid = request.getParameter("mainid"); } } if (request.getParameter("mainstring") == null){ mainstring = ""; } else { if (request.getParameter("mainstring") != null){ mainstring = request.getParameter("mainstring"); } } if (request.getParameter("secid") == null){ secid = "0"; } else { if (request.getParameter("secid") != null){ secid = request.getParameter("secid"); } } if (request.getParameter("subpath") == null){ subpath = ""; } else { if (request.getParameter("subpath") != null){ subpath = request.getParameter("subpath"); } } Map parameters = new HashMap(); parameters.put("mainid", new Integer(mainid)); parameters.put("mainstring", mainstring); parameters.put("secid", new Integer(secid)); parameters.put("subpath", subpath); parameters.put("SUBREPORT_DIR", context.getRealPath(rptFolder + "//" + subpath + "//" + "rptFatCanFor_subFor.jasper")); parameters.put("SUB_SUBREPORT_DIR", context.getRealPath(rptFolder + "//" + subpath + "//" + "rptFatCanFor_subFor_subFat.jasper")); Connection Conn = null; DAOMain rptDAO = new DAOMain(); try { Conn = rptDAO.myCn(); } catch (InstantiationException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IllegalAccessException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (ClassNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { jp = JasperFillManager.fillReport(context.getResourceAsStream("/" + rptFolder + "/" + subpath + "/" + rptFileName + ".jasper"), parameters, Conn); } catch (JRException e) { // TODO Auto-generated catch block e.printStackTrace(); } ServletOutputStream outStream = response.getOutputStream(); try { JasperExportManager.exportReportToPdfStream(jp, outStream); } catch (JRException e) { // TODO Auto-generated catch block e.printStackTrace(); } } /* (non-Java-doc) * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doGet(request,response); } } Link to comment Share on other sites More sharing options...
archimede76 Posted March 31, 2009 Author Share Posted March 31, 2009 please, help me... Is the description good? Thank... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now