Torna indietro   Hardware Upgrade Forum > Software > Programmazione

LG UltraGear evo GM9: 27 pollici, 5K, Mini LED e Dual Mode
LG UltraGear evo GM9: 27 pollici, 5K, Mini LED e Dual Mode
Hyper Mini LED con 2.304 zone, DisplayPort 2.1 e Dual Mode: 5K a 165 Hz oppure QHD a 330 Hz: LG propone un monitor da gioco ma dalla buona versatilità creativa, con prestazioni interessanti e un listino di 1.220 euro. Peccato l'alimentatore ingombrante
Motorola edge 70 Fusion FIFA World Cup 26 Edition: un ottimo smartphone per i fan del calcio
Motorola edge 70 Fusion FIFA World Cup 26 Edition: un ottimo smartphone per i fan del calcio
Motorola edge 70 Fusion FIFA World Cup 26 Edition porta la maglia iridata su uno smartphone accessibile: display Extreme AMOLED da 6,78 pollici a 144Hz, fotocamera Sony LYTIA 710 con moto ai, Snapdragon 7s Gen 3 abbinato a 8GB di RAM, batteria da 5200 mAh con ricarica TurboPower a 68W e certificazione IP68/IP69, il tutto in una veste PANTONE Silhouette con logo dorato a 24 carati, moto buds bass incluse in confezione e contenuti software dedicati ai Mondiali 2026
Renault 5 elettrica al giudizio definitivo: solo stupore iniziale o premi meritati?
Renault 5 elettrica al giudizio definitivo: solo stupore iniziale o premi meritati?
Dopo più di un anno dal primo test drive ci siamo rimessi al volante della Renault 5 E-Tech Electric, questa volta utilizzandola come prima auto per circa due settimane. Scoprite con noi se il progetto convince ancora
Tutti gli articoli Tutte le news

Vai al Forum
Rispondi
 
Strumenti
Old 27-02-2007, 17:16   #1
osvit
Senior Member
 
L'Avatar di osvit
 
Iscritto dal: Jan 2001
Città: Milano
Messaggi: 664
[JSP] richiamare Crystal Reports XI da pagina jsp

Ciao, vorrei visualizzare un report fatto con C.R. XI richiamandolo da una pagina jsp. Ho provato ad utilizzare un file di esempio trova nella cartella d'installazione di C.R. ma non ci capisco molto
Mi date un consiglio?
Grazie

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<html:html>
<HEAD>
<%@ page
language="java"
contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"
session="true"
%>
<%@ page import="com.crystaldecisions.report.web.viewer.CrystalReportViewer"%>
<%@ page import="com.crystaldecisions.sdk.occa.report.reportsource.IReportSource"%>
<%@ page import="com.crystaldecisions.xml.serialization.*"%>
<%@ page import="javax.servlet.http.HttpServletRequest"%>
<%@ page import="javax.servlet.http.HttpServletRequest"%>
<%@ page import="javax.servlet.http.HttpServletResponse"%>
<%@ page import="java.io.*"%>
<%
String CLOSED_RPT_ID = "closedreportid";
String RPT_ID = "reportid";
String RPT_SOURCE = "D:\\Progetti\\report\\prova.rpt";

(RPT_SOURCE="D:\\Progetti\\report\\prova.rpt");

//String closeRptID = request.getParameter(CLOSED_RPT_ID);
//String reportID = request.getParameter(RPT_ID);
//String serializedRptSrc = request.getParameter(RPT_SOURCE);
String closeRptID = "closedreportid";
String reportID = "reportid";
String serializedRptSrc = "D:\\Progetti\\WeFid\\online\\wefidWeb\\report\\prova.rpt";

if (closeRptID != null && closeRptID.length() > 0)
{
// Clear the report source in session with the given closedreportid
session.removeAttribute(closeRptID);
}

if (reportID != null && reportID.length() > 0)
{
CrystalReportViewer viewer = new CrystalReportViewer();
viewer.setName("htmlpreview");
viewer.setHasRefreshButton(false);
viewer.setHasExportButton(false);
viewer.setHasPrintButton(false);
viewer.setOwnForm(true);
viewer.setOwnPage(true);

if (serializedRptSrc != null && serializedRptSrc.length() > 0)
{
IReportSource reportSource = null;

// Got a seralizedRprtSrc string
// need to deserialize the report source string and pass to viewer
byte[] byteRptSrc = serializedRptSrc.getBytes();
ByteArrayInputStream byteInStream = new ByteArrayInputStream(byteRptSrc);

try
{
XMLObjectSerializer serializer = new XMLObjectSerializer();
SaveOption saveOpt = serializer.getSaveOption();
saveOpt.setExcludeNullObjects(true);
// Enabled since server is ready.
saveOpt.setSkipWritingIdenticalObject(true);

reportSource = (IReportSource)serializer.load(byteInStream);
}
catch (Exception e)
{
e.printStackTrace();
out.write("Error deserializing report source.");
return;
}
finally
{
byteInStream.close();
}
viewer.setReportSource(reportSource);
session.setAttribute(reportID, viewer.getReportSource());
}
else
{
// Try to load report source from session
viewer.setReportSource((IReportSource) session.getAttribute(reportID));
}
viewer.setURI(request.getRequestURI() + "?" + RPT_ID + "=" + reportID);
viewer.processHttpRequest(request, response, application, null);
}
%>

<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="IBM WebSphere Studio">
<TITLE></TITLE>
</HEAD>

<BODY>
<P>Place content here.</P>
</BODY>
</html:html>
__________________
Gli immobiliaristi sono bestie che non puzzano, ma dove passano loro non cresce più l'erba...
osvit è offline   Rispondi citando il messaggio o parte di esso
Old 28-02-2007, 09:16   #2
osvit
Senior Member
 
L'Avatar di osvit
 
Iscritto dal: Jan 2001
Città: Milano
Messaggi: 664
up
__________________
Gli immobiliaristi sono bestie che non puzzano, ma dove passano loro non cresce più l'erba...
osvit è offline   Rispondi citando il messaggio o parte di esso
Old 01-03-2007, 21:09   #3
osvit
Senior Member
 
L'Avatar di osvit
 
Iscritto dal: Jan 2001
Città: Milano
Messaggi: 664
up
__________________
Gli immobiliaristi sono bestie che non puzzano, ma dove passano loro non cresce più l'erba...
osvit è offline   Rispondi citando il messaggio o parte di esso
Old 05-03-2007, 15:19   #4
osvit
Senior Member
 
L'Avatar di osvit
 
Iscritto dal: Jan 2001
Città: Milano
Messaggi: 664
up
__________________
Gli immobiliaristi sono bestie che non puzzano, ma dove passano loro non cresce più l'erba...
osvit è offline   Rispondi citando il messaggio o parte di esso
Old 05-03-2007, 17:56   #5
Psylo
Junior Member
 
L'Avatar di Psylo
 
Iscritto dal: Aug 2006
Città: Pescara
Messaggi: 62
[OT]

il tuo avatar mi sta facendo svalvolare....

[/OT]
__________________
"I giganti sembrano tali solo a coloro che vivono in ginocchio.."
Psylo è offline   Rispondi citando il messaggio o parte di esso
Old 05-03-2007, 19:11   #6
DvL^Nemo
Senior Member
 
L'Avatar di DvL^Nemo
 
Iscritto dal: Nov 2001
Città: 100 metri dal mare
Messaggi: 4856
Adesso non sono a lavoro, quindi non ho nulla sottomano, ma domani ti posto qualcosa CRXI e JSP,nel mio caso e' un report che si aggancia ad un database
Ciao !
DvL^Nemo è offline   Rispondi citando il messaggio o parte di esso
Old 06-03-2007, 13:25   #7
osvit
Senior Member
 
L'Avatar di osvit
 
Iscritto dal: Jan 2001
Città: Milano
Messaggi: 664
Quote:
Originariamente inviato da DvL^Nemo Guarda i messaggi
Adesso non sono a lavoro, quindi non ho nulla sottomano, ma domani ti posto qualcosa CRXI e JSP,nel mio caso e' un report che si aggancia ad un database
Ciao !
Ok grazie.
Potresti anche dirmi quali sono i jar da utilizzare? Nella cartella "Program Files\Common Files\Crystal report XI\java\lib" ce ne sono ben 43
__________________
Gli immobiliaristi sono bestie che non puzzano, ma dove passano loro non cresce più l'erba...
osvit è offline   Rispondi citando il messaggio o parte di esso
Old 06-03-2007, 13:32   #8
osvit
Senior Member
 
L'Avatar di osvit
 
Iscritto dal: Jan 2001
Città: Milano
Messaggi: 664
Quote:
Originariamente inviato da Psylo Guarda i messaggi
[OT]

il tuo avatar mi sta facendo svalvolare....

[/OT]
__________________
Gli immobiliaristi sono bestie che non puzzano, ma dove passano loro non cresce più l'erba...
osvit è offline   Rispondi citando il messaggio o parte di esso
Old 06-03-2007, 13:46   #9
DvL^Nemo
Senior Member
 
L'Avatar di DvL^Nemo
 
Iscritto dal: Nov 2001
Città: 100 metri dal mare
Messaggi: 4856
Comunque nel mio caso i passi erano 2 per lanciare il report
1) Servlet che chiama la JSP di accesso al database, passando username, password e altre cose..
2) JSP che richiama il report

Codice:
package xxx.yyyy;

import java.io.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import javax.servlet.*;
import javax.servlet.http.*;

import tchn.login.ConnectionHolder;


public class XXX extends HttpServlet {
	
    private final static String connectionURL = Risorse.getConnectionURL();

    //Risorse.getDataString("server_ip")
    private final static String user = "XXX";
    private final static String password = "YYY";
    
    private static final boolean DEBUG = true;

    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {		
		
    	RequestDispatcher reqDis=request.getRequestDispatcher("view/jrc_database_logon.jsp");
    	String sUrlDb=request.getParameter("URLDB");
    	String sId=request.getParameter("sId");
    	java.sql.Connection connection=getConnection(request.getSession(),sUrlDb);    	
    	request.setAttribute("conn",connection);
    	request.setAttribute("sId",sId);
    	reqDis.forward(request,response);
    }

	/** Process the HTTP Post request */
    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
		
		doGet(request, response);
    }
    
    private Connection getConnection(HttpSession session,String sUrlDb ){
        Connection con=null;
        // Synchronize: Without this two holders might be created for one client
        synchronized (session) {
          // Try getting the connection holder for this client
          ConnectionHolder holder =
            (ConnectionHolder) session.getAttribute("servletapp.connection");

          // Create (and store) a new connection and holder if necessary
          if (holder == null) {
            try {
              Class.forName("oracle.jdbc.driver.OracleDriver");
              Connection cn=DriverManager.getConnection(sUrlDb,user,password);
              holder = new ConnectionHolder(cn);
              session.setAttribute("servletapp.connection", holder);
            }
            catch (SQLException e) {
            	e.printStackTrace();
            } catch (ClassNotFoundException e2) {
                e2.printStackTrace();
            }
          }
        }
        con=((ConnectionHolder)session.getAttribute("servletapp.connection")).getConnection();
        return con;
    }
	
}
2) JSP "jrc_database_logon.jsp"

Codice:
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<%@page import="com.crystaldecisions.reports.sdk.*" %>
<%@page import="com.crystaldecisions.sdk.occa.report.reportsource.*" %>
<%@page import="com.crystaldecisions.sdk.occa.report.lib.*" %>
<%@page import="com.crystaldecisions.sdk.occa.report.data.*" %>
<%@page import="com.crystaldecisions.report.web.viewer.*" %>
<%@page import="java.util.*"%>
<%@page import="java.sql.*"%>

<%

/* 
* Applies to Versions:	XI
* Date Created: February 9, 2005
* Description: This sample opens a report connected to pubs Sample database on
*              MS SQL Server using the Java Reporting Component (JRC) SDK.  
*              The report uses a JDBC connection in the designer.
*              The code passes in the user name and password for the database
*              via a ConnectionInfos object through the CrystalReportViewer.            
* Author: MAE
*/

%>
<%
	java.sql.Connection connection=(java.sql.Connection)request.getAttribute("conn");
	String sId=request.getAttribute("sId").toString();
%>

<%
	//Use the relative path to the report; the physical or full qualified URL cannot
	// be used.
	String reportName = "reports/Report.rpt";
	
	//Database username and password
	String userName = "XXX";
	String password = "YYY";
    
	 try{
		 ReportClientDocument clientDoc = new ReportClientDocument();
		 clientDoc.open(reportName, 0);

		 Object oReportSource = clientDoc.getReportSource();
         session.setAttribute("reportSource", oReportSource);

         ResultSet resultSet = getResultSetFromQuery("SELECT * FROM STAMPA WHERE ID='"+sId+"'",connection,session, ResultSet.TYPE_SCROLL_INSENSITIVE); 
		
    	//Look up existing table in the report to set the datasource for and obtain its alias.  This table must 
    	//have the same schema as the Resultset that is being pushed in at runtime.  The table could be created 
    	//from a Field Definition File, a Command Object, or regular database table.  As long the Resultset
    	//schema has the same field names and types, then the Resultset can be used as the datasource for the table.  
    	String tableAlias = clientDoc.getDatabaseController().getDatabase().getTables().getTable(0).getAlias();
    			
    	//Push the Java ResultSet into the report.  This will then be the datasource of the report.
    	clientDoc.getDatabaseController().setDataSource(resultSet, tableAlias , "resultsetTable");
    	
    	//Store the report source in session, will be used by the CrystalReportViewer.
    	session.setAttribute("reportSource", clientDoc.getReportSource());

		CrystalReportViewer oCrystalReportViewer = new CrystalReportViewer(); 
		
		oCrystalReportViewer.setReportSource(clientDoc.getReportSource());
		
		
	    ConnectionInfos oConnectionInfos = new ConnectionInfos();
	    ConnectionInfo oConnectionInfo = new ConnectionInfo();

	    //Set username and password for the report's database
	    oConnectionInfo.setUserName(userName);
	    oConnectionInfo.setPassword(password);

	    //Add object to collection
	    oConnectionInfos.add(oConnectionInfo);

	    session.setAttribute("oConnectionInfos", oConnectionInfos);

	    oCrystalReportViewer.setDatabaseLogonInfos(oConnectionInfos);
		
		//set viewer attributes
		oCrystalReportViewer.setOwnPage(true);
		oCrystalReportViewer.setOwnForm(true);
	  
		//set the CrystalReportViewer print mode
		//oCrystalReportViewer.setPrintMode(CrPrintMode.ACTIVEX);
		oCrystalReportViewer.setPrintMode(CrPrintMode.PDF);
		  
        oCrystalReportViewer.setDisplayGroupTree(false);
        
		Fields oFields = new Fields();		 
	    //setDiscreteParameterValue(oFields, "sessionId", reportName, sessionId);

	    //Push Fields collection into session so it can be retrieved by the viewer and set
	    //at view time.
	    oCrystalReportViewer.setParameterFields(oFields); 

		session.setAttribute("parameterFields", oFields);  
		
		oCrystalReportViewer.setSeparatePages(true);
		
		oCrystalReportViewer.refresh();
		session.setAttribute("refreshed", "true");
	

	    oCrystalReportViewer.processHttpRequest(request, response, getServletConfig().getServletContext(), null); 	 
		 
	}
	catch(Exception e){
		out.print(e);
	}
%>
<%!
/*
 * Utility function to set values for the discrete parameters in the report.  The report parameter value is set
 * and added to the Fields collection, which can then be passed to the viewer so that the user is not prompted
 * for parameter values.  
 */
private void setDiscreteParameterValue(Fields oFields, String paramName, String reportName, Object value) {
	
	//Create a ParameterField object for each field that you wish to set.  
    ParameterField oParameterField = new ParameterField();

    //You must set the report name. 
    //Set the report name to an empty string if your report does not contain a
    //subreport; otherwise, the report name will be the name of the subreport
    oParameterField.setReportName(reportName);

    //Create a Values object and a ParameterFieldDiscreteValue object for each 
    //object for each parameter field you wish to set.
    //If a ranged value is being set, a ParameterFieldRangeValue object should 
    //be used instead of the discrete value object.
    Values oValues = new Values();
    ParameterFieldDiscreteValue oParameterFieldDiscreteValue = new ParameterFieldDiscreteValue();
    
    //Set the name of the parameter.  This must match the name of the parameter as defined in the
    //report.
    oParameterField.setName(paramName);
    oParameterFieldDiscreteValue.setValue(value);

    //Add the parameter field values to the Values collection object.
    oValues.add(oParameterFieldDiscreteValue);

    //Set the current Values collection for each parameter field.
    oParameterField.setCurrentValues(oValues);

    //Add parameter field to the Fields collection.  This object is then passed to the
    //viewer as the collection of parameter fields values set. 
    oFields.add(oParameterField);
        
}
%>
<%!
	/**
	 * Simple utility function for obtaining result sets that will be pushed into the report.  
	 * This is just standard querying of a Java result set and does NOT involve any 
	 * Crystal JRC SDK functions.  
	 */
	private static ResultSet getResultSetFromQuery(String query,java.sql.Connection connection,HttpSession session, int scrollType) throws SQLException, ClassNotFoundException {

		//Load JDBC driver for the database that will be queried.  
//		Class.forName("oracle.jdbc.driver.OracleDriver");
		
		//Construct JDBC connection.
//		final String DBUSERNAME = "XXX";
//		final String DBPASSWORD = "YYY";
//		final String CONNECTION_URL = "jdbc:oracle:thin:@127.0.0.1:1521:PIPPO";
		
//		java.sql.Connection connection = DriverManager.getConnection(CONNECTION_URL, DBUSERNAME, DBPASSWORD); 
		//java.sql.Connection connection =((tchn.login.ConnectionHolder)session.getAttribute("servletapp.connection")).getConnection();
		java.sql.Statement statement = connection.createStatement(scrollType, ResultSet.CONCUR_READ_ONLY);
		
		//Execute query and return result sets.
		return statement.executeQuery(query);

	}
%>
Modifica il tutto per quello che serve a te ovviamente, dovrebbe andare..

Questi sono tutti i jar che mi ritrovo nella cartella lib, alcuni non sono di Crystal Report..

Codice:
Concurrent.jar
CRDBJavaServerCommon.jar
CRDBXMLServer.jar
CrystalCharting.jar
CrystalCommon.jar
CrystalContentModels.jar
CrystalExporters.jar
CrystalExportingBase.jar
CrystalFormulas.jar
CrystalQueryEngine.jar
CrystalReportEngine.jar
CrystalReportingCommon.jar
icu4j.jar
jrcerom.jar
keycodeDecoder.jar
log4j.jar
MetafileRenderer.jar
ojdbc14.jar
ORACLE7JDBC-JDK1.2.jar
rascore.jar
reportviewerbean.jar
rpoifs.jar
serialization.jar
StringUtil.jar
URIUtil.jar
webreporting.jar
xercesImpl.jar
xml-apis.jar
Ciao !

Ultima modifica di DvL^Nemo : 06-03-2007 alle 13:54.
DvL^Nemo è offline   Rispondi citando il messaggio o parte di esso
 Rispondi


LG UltraGear evo GM9: 27 pollici, 5K, Mini LED e Dual Mode LG UltraGear evo GM9: 27 pollici, 5K, Mini LED e...
Motorola edge 70 Fusion FIFA World Cup 26 Edition: un ottimo smartphone per i fan del calcio Motorola edge 70 Fusion FIFA World Cup 26 Editio...
Renault 5 elettrica al giudizio definitivo: solo stupore iniziale o premi meritati? Renault 5 elettrica al giudizio definitivo: solo...
HONOR CHOICE Projector Air Pro: piccolo, portatile e con Netflix HONOR CHOICE Projector Air Pro: piccolo, portati...
ASUS ProArt GoPro Edition è il notebook compatto per chi crea ASUS ProArt GoPro Edition è il notebook c...
Oltre 1.500 miliardi di dollari: il merc...
'Sorry, typo': l'IA cancella tutto il pr...
The Legend of Zelda sarà l'ultima...
NVIDIA CMP 170 HX: il mining l'aveva abb...
Philips Shaver S9000 a 181,99€: il rasoi...
Samsung Galaxy S26 FE si mostra nei prim...
Il nuovo sensore da 200MP di Samsung è m...
Clamoroso ritorno in Ubisoft: ecco chi d...
1600W, tecnologia GaN, display LCD e fin...
Addio Google Translate? Questo traduttor...
Honor al lavoro sul nuovo MagicPad: in a...
Blue Origin rende note le cause dell'esp...
Le prime AirPods con fotocamere e IA pot...
I dati della sonda spaziale NASA New Hor...
Si sposta su quattro zampe e impugna una...
Chromium
GPU-Z
OCCT
LibreOffice Portable
Opera One Portable
Opera One 106
CCleaner Portable
CCleaner Standard
Cpu-Z
Driver NVIDIA GeForce 546.65 WHQL
SmartFTP
Trillian
Google Chrome Portable
Google Chrome 120
VirtualBox
Tutti gli articoli Tutte le news Tutti i download

Strumenti

Regole
Non Puoi aprire nuove discussioni
Non Puoi rispondere ai messaggi
Non Puoi allegare file
Non Puoi modificare i tuoi messaggi

Il codice vB è On
Le Faccine sono On
Il codice [IMG] è On
Il codice HTML è Off
Vai al Forum


Tutti gli orari sono GMT +1. Ora sono le: 00:04.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Served by www3v