<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>servlet | www.valeriofinazzo.it</title>
	<atom:link href="http://www.valeriofinazzo.it/wordpress/tag/servlet/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.valeriofinazzo.it/wordpress</link>
	<description>Il sito dell&#039;ingegnere Valerio Finazzo</description>
	<lastBuildDate>Thu, 19 Jun 2014 20:23:36 +0000</lastBuildDate>
	<language>it-IT</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.0.3</generator>
	<item>
		<title>JASPERREPORTS TUTORIAL &#8211; 7 &#8211; INTEGRARE IL REPORT IN UNA SERVLET</title>
		<link>http://www.valeriofinazzo.it/wordpress/2014/06/jasperreports-tutorial-7-integrare-il-report-in-una-servlet/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Thu, 19 Jun 2014 20:19:40 +0000</pubDate>
				<category><![CDATA[JASPERREPORTS]]></category>
		<category><![CDATA[ireport]]></category>
		<category><![CDATA[jasperreports]]></category>
		<category><![CDATA[servlet]]></category>
		<guid isPermaLink="false">http://www.valeriofinazzo.it/wordpress/?p=152</guid>

					<description><![CDATA[<p>Nell&#8217;articolo di oggi vedremo come rendere disponibile il report all&#8217;interno di una web application. Il report sarà aperto invocando una url particolare e reso disponibile direttamente nel browser. Primo passo: creare la web application. Per fare questo ci avvaliamo di maven e uno dei suoi archetipi. [crayon-64138107aafbe060877337/] Creato il progetto possiamo importarlo in eclipse tramite &#8230; <a href="http://www.valeriofinazzo.it/wordpress/2014/06/jasperreports-tutorial-7-integrare-il-report-in-una-servlet/" class="more-link">Continua la lettura di <span class="screen-reader-text">JASPERREPORTS TUTORIAL &#8211; 7 &#8211; INTEGRARE IL REPORT IN UNA SERVLET</span> <span class="meta-nav">&#8594;</span></a></p>
The post <a href="http://www.valeriofinazzo.it/wordpress/2014/06/jasperreports-tutorial-7-integrare-il-report-in-una-servlet/">JASPERREPORTS TUTORIAL – 7 – INTEGRARE IL REPORT IN UNA SERVLET</a> first appeared on <a href="http://www.valeriofinazzo.it/wordpress">www.valeriofinazzo.it</a>.]]></description>
										<content:encoded><![CDATA[<p style="color: #0d293f; text-align: justify;">Nell&#8217;articolo di oggi vedremo come rendere disponibile il report all&#8217;interno di una web application. Il report sarà aperto invocando una url particolare e reso disponibile direttamente nel browser.</p>
<p style="color: #0d293f; text-align: justify;">Primo passo: creare la web application.</p>
<p style="color: #0d293f; text-align: justify;">Per fare questo ci avvaliamo di maven e uno dei suoi archetipi.</p>
<p></p><pre class="crayon-plain-tag">mvn archetype:create 
-DgroupId=it.finazzo.web 
-DartifactId=ReportJasperWeb 
-DarchetypeArtifactId=maven-archetype-webapp</pre><p></p>
<p style="color: #0d293f; text-align: justify;">Creato il progetto possiamo importarlo in eclipse tramite la direttiva mvn eclipse:eclipse.</p>
<p style="color: #0d293f; text-align: justify;">Secondo Passo: definire la servlet per l&#8217;export</p>
<p style="color: #0d293f; text-align: justify;">A questo punto dichiaramo la servlet che si preoccuperà di esportare il report in formato pdf. Definiamo nel file web.xml la servlet e l&#8217;url pattern che la attiva</p>
<p></p><pre class="crayon-plain-tag">&lt;servlet&gt;
  &lt;servlet-name&gt;Manager&lt;/servlet-name&gt;
  &lt;servlet-class&gt;it.finazzo.servlet.Manager&lt;/servlet-class&gt;
  &lt;/servlet&gt;  
  &lt;servlet-mapping&gt;
  	&lt;servlet-name&gt;Manager&lt;/servlet-name&gt;
  	&lt;url-pattern&gt;/manager&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
&lt;/web-app&gt;</pre><p></p>
<p style="color: #0d293f; text-align: justify;">Terzo Passo: implementare la funzione di export.</p>
<p></p><pre class="crayon-plain-tag">JRDataSource ds = new it.finazzo.ds.DataSource();
String reportFileName = 
getServletContext().getRealPath(&quot;WEB-INF/classes/reportFromXml.jrxml&quot;);
JasperReport jasperReport = null;
jasperReport = JasperCompileManager.compileReport(reportFileName);
JasperPrint jasperPrint = null;
jasperPrint = JasperFillManager.fillReport(jasperReport, new HashMap(), ds );
JasperExportManager.exportReportToPdfStream(jasperPrint, resp.getOutputStream());</pre><p></p>
<p style="color: #0d293f; text-align: justify;">Recuperiamo il file jrxml dal classpath e usiamo il metodo per esportare il report direttamente nell&#8217;output stream della response, con l&#8217;effetto di aprire il file direttamente nel browser quando invochiamo l&#8217;url http://localhost:9000/Report/manager</p>
<p style="color: #0d293f; text-align: justify;"><a style="color: #2675b5;" title="Jasper Reports - Esportare report tramite servlet" href="http://www.valeriofinazzo.it/joomla/file/ReportJasperWeb.zip" target="_blank">Qui </a>sono disponibili i sorgenti per provare in locale.</p>
<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fwww.valeriofinazzo.it%2Fwordpress%2F2014%2F06%2Fjasperreports-tutorial-7-integrare-il-report-in-una-servlet%2F&amp;linkname=JASPERREPORTS%20TUTORIAL%20%E2%80%93%207%20%E2%80%93%20INTEGRARE%20IL%20REPORT%20IN%20UNA%20SERVLET" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.valeriofinazzo.it%2Fwordpress%2F2014%2F06%2Fjasperreports-tutorial-7-integrare-il-report-in-una-servlet%2F&amp;linkname=JASPERREPORTS%20TUTORIAL%20%E2%80%93%207%20%E2%80%93%20INTEGRARE%20IL%20REPORT%20IN%20UNA%20SERVLET" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fwww.valeriofinazzo.it%2Fwordpress%2F2014%2F06%2Fjasperreports-tutorial-7-integrare-il-report-in-una-servlet%2F&amp;linkname=JASPERREPORTS%20TUTORIAL%20%E2%80%93%207%20%E2%80%93%20INTEGRARE%20IL%20REPORT%20IN%20UNA%20SERVLET" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_whatsapp" href="https://www.addtoany.com/add_to/whatsapp?linkurl=http%3A%2F%2Fwww.valeriofinazzo.it%2Fwordpress%2F2014%2F06%2Fjasperreports-tutorial-7-integrare-il-report-in-una-servlet%2F&amp;linkname=JASPERREPORTS%20TUTORIAL%20%E2%80%93%207%20%E2%80%93%20INTEGRARE%20IL%20REPORT%20IN%20UNA%20SERVLET" title="WhatsApp" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_google_gmail" href="https://www.addtoany.com/add_to/google_gmail?linkurl=http%3A%2F%2Fwww.valeriofinazzo.it%2Fwordpress%2F2014%2F06%2Fjasperreports-tutorial-7-integrare-il-report-in-una-servlet%2F&amp;linkname=JASPERREPORTS%20TUTORIAL%20%E2%80%93%207%20%E2%80%93%20INTEGRARE%20IL%20REPORT%20IN%20UNA%20SERVLET" title="Gmail" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=http%3A%2F%2Fwww.valeriofinazzo.it%2Fwordpress%2F2014%2F06%2Fjasperreports-tutorial-7-integrare-il-report-in-una-servlet%2F&#038;title=JASPERREPORTS%20TUTORIAL%20%E2%80%93%207%20%E2%80%93%20INTEGRARE%20IL%20REPORT%20IN%20UNA%20SERVLET" data-a2a-url="http://www.valeriofinazzo.it/wordpress/2014/06/jasperreports-tutorial-7-integrare-il-report-in-una-servlet/" data-a2a-title="JASPERREPORTS TUTORIAL – 7 – INTEGRARE IL REPORT IN UNA SERVLET"></a></p>The post <a href="http://www.valeriofinazzo.it/wordpress/2014/06/jasperreports-tutorial-7-integrare-il-report-in-una-servlet/">JASPERREPORTS TUTORIAL – 7 – INTEGRARE IL REPORT IN UNA SERVLET</a> first appeared on <a href="http://www.valeriofinazzo.it/wordpress">www.valeriofinazzo.it</a>.]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
