Jump to content
We've recently updated our Privacy Statement, available here ×

Jasper Viewer and servelt issue


juanmanuelsanch

Recommended Posts

hi ! Im having this "weird" issue. I have this piece of code that gets the reports and executes them


String reporte = request.getParameter("Reporte a generar");
                String formato = request.getParameter("Formato");
 
                HashMap hm = null;
                System.out.println("Usage: ReportGenerator ....");
 
                System.out.println("Start ....");
 
                String path = getServletContext().getRealPath("/");
 
                System.out.println("PATH " + path);
 
                // Get jasper report
                String jrxmlFileName = path + "/Reportes/" + reporte + ".jrxml";
                String jasperFileName = path + "/Reportes/" + reporte + ".jasper";
 
                JasperCompileManager.compileReportToFile(jrxmlFileName, jasperFileName);
 
                 InitialContext ctx = new InitialContext();
                 DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/MedPro");
                 Connection conexion = ds.getConnection();
                // Create arguments
                // Map params = new HashMap();
                hm = new HashMap();
 
                // Generate jasper print
 
                JasperPrint jprint = (JasperPrint) JasperFillManager.fillReport(jasperFileName, hm, conexion);
 
                JasperViewer.viewReport(jprint, false);
               conexion.close();


This code works well in my dev machine, but when I move the app to the server at the place where its going the be used. The viewer dosent show, there is no error, exception or anything, it just waits forever. What could be causing this?

Thanks a lot !

 

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Hi,

When you'll learn more about web application architecture, you'll realize why Swing applications (which are by definition client side applications, or desktop applications), cannot work in a server (they actually do, but I'm sure you don't want them pop-up on the server, do you?).

So, please read more documentation about web applications and then try the /demo/samples/webapp sample provided with the JasperReports project distribution and learn how reports could be displayed using a Swing applet, if you still think you need to use the JRViewer.

I hope this helps.
Teodor

 

Link to comment
Share on other sites

  • 2 weeks later...

well I have tried them but Im still very much confused. First of all thanks for the help, but I think the documentation is not long and explained enough, specially for new people like me.

So now Im trying to do something like this to fill the applet depeding on the choose of the user, so my code looks like

InitialContext ctx = new InitialContext();
                 DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/MedPro");
                 Connection conexion = ds.getConnection();
                // Create arguments
                // Map params = new HashMap();
                 HashMap hm = null;
                 hm = new HashMap();

                // Generate jasper print

                jasperPrint = (JasperPrint) JasperFillManager.fillReport(jasperFileName, hm, conexion);

   // jasperPrint = (JasperPrint)JRLoader.loadObject(jasperFileName);
   
        JRViewerSimple viewer = new JRViewerSimple(jasperPrint);
     this.pnlMain.add(viewer, BorderLayout.CENTER);
                    conexion.close();

and my jsp with the appplet

<APPLET CODEBASE="SvMedPro" CODE="beans.EmbeddedViewerApplet.class" ARCHIVE = "jasperreports-3.1.2-applet.jar" WIDTH = "600" HEIGHT = "400" ></XMP>

Something I dont understand is the Archive tag, do you use it in the example because is needed for all the applet applications? So it remains the same for all? 

I say this because Im getting java.lang.ClassFormatError: Incompatible magic value 1165128303 so Im supposing the class file is being found but not the jar.

Thanks for your help.

 

 

 



Post Edited by Juan Manuel Sanchez at 01/29/09 16:19
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...