<%@ page import="java.util.*,java.io.*,jet.cs.util.*,jet.server.api.*,jet.server.api.http.HttpUtil" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Embedded Reporting for Web Application with JReport</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="report1.css" rel="stylesheet" type="text/css">
<link href="basic.css" rel="stylesheet" type="text/css">
</head>

<body>
<table width="85%"  border="0" cellspacing="15" cellpadding="0">
  <tr>
    <td width="180"><img src="images/logo.gif" alt="JReport Logo" width="166" height="41"></td>
    <td valign="bottom"><table width="100%"  border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td align="right"><span class="title">Embedded Reporting for Web Application</span></td>
      </tr>
      <tr>
        <td height="6px;"><img name="" src="" width="1" height="1" alt=""></td>
      </tr>
      <tr>
        <td height="1" bgcolor="#9F9F9F" style="border-bottom:1px solid #DFDFDF; "><img name="" src="" width="1" height="1" alt=""></td>
      </tr>
    </table></td>
  </tr>
  <tr valign="top">
    <td width="180" style="border:1px solid #DFDFDF; background-image:url(images/leftTab_bg.gif); background-repeat:repeat-y; "><table width="180"  border="0" cellpadding="2" cellspacing="3">
      <tr>
        <td colspan="2"><img src="images/bullet.gif" width="11" height="11" align="absmiddle"> <strong>Our Products</strong></td>
        </tr>
      <tr valign="top">
        <td width="9" align="center">-</td>
        <td width="142"><a href="http://www.jinfonet.com/products/designer.htm" target="_blank">JReport Designer</a></td>
      </tr>
      <tr valign="top">
        <td align="center">-</td>
        <td><a href="http://www.jinfonet.com/products/server.htm" target="_blank">JReport Enterprise Server</a></td>
      </tr>
      <tr valign="top">
        <td align="center">-</td>
        <td><a href="http://www.jinfonet.com/faq" target="_blank">FAQs</a></td>
      </tr>
      <tr valign="top">
        <td align="center">&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td colspan="2"><img src="images/bullet.gif" width="11" height="11" align="absmiddle"> <strong>Evaluate JReport</strong></td>
      </tr>
      <tr valign="top">
        <td align="center">-</td>
        <td><a href="http://www.jinfonet.com/support/register_1_1.htm" target="_blank">Download JReport</a></td>
      </tr>
      <tr valign="top">
        <td align="center">-</td>
        <td><a href="http://www.jinfonet.com/contact/contact_dem.htm" target="_blank">Schedule a Live Demo</a></td>
      </tr>
      <tr valign="top">
        <td align="center">&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td colspan="2"><img src="images/bullet.gif" width="11" height="11" align="absmiddle"> <strong>Contact Us: </strong></td>
      </tr>
      <tr valign="top">
        <td align="center">-</td>
        <td>Jinfonet Sales<br>
            <a href="mailto:sales@jinfonet.com">sales@jinfonet.com</a></td>
      </tr>
      <tr valign="top">
        <td align="center">-</td>
        <td>Jinfonet Support <br>
            <a href="mailto:support@jinfonet.com">support@jinfonet.com</a></td>
      </tr>
      <tr valign="top">
        <td align="center">-</td>
        <td>Jinfonet Marketing <br>
            <a href="mailto:marketing@jinfonet.com">marketing@jinfonet.com</a></td>
      </tr>
      <tr valign="top">
        <td align="center">-</td>
        <td>Phone<br>
      301-838-5560</td>
      </tr>
      <tr valign="top">
        <td align="center">-</td>
        <td>Fax<br>
      240-465-0355</td>
      </tr>
    </table></td>
    <td><p>If we change the web CSS file the below demo report style should change in the same time.</p>
      <div style="position:relative;">
        <%
			RptServer server = HttpUtil.getHttpRptServer(request);
			System.out.println("\n========server="+server);
			
			String exportDir = new File(pageContext.getServletContext().getRealPath(request.getServletPath())).getParent();
			System.out.println("========exportDir="+exportDir); 

			String catalog = "/SampleReports/SampleReports.cat";
			String rptName = "/SampleReports/CustomerAnalysis.cls";

			//set report properties
			Properties props = new Properties();
			props.put(APIConst.TAG_REPORT_LANGUAGE, "en_US");
			
			//set value of parameter "p_StartDate&p_EndDate".
			props.put(APIConst.TAG_PARAM_PREFIX + "p_StartDate", "January 1, 2008");
			props.put(APIConst.TAG_PARAM_PREFIX + "p_EndDate", "December 31, 2009");
			
			OutputStream htmlStream = new ByteArrayOutputStream();
			//Specify a name with its full path for the report result's .css file generated by JReport automatically.
			OutputStream cssStream =  new FileOutputStream(new File(exportDir, "report1.css")); 
			
			props.put(APIConst.TAG_HTML_IS_BODY_STREAM,"true"); 
			props.put(APIConst.TAG_HTML_BODY_OUTSTREAM, htmlStream);
			props.put(APIConst.TAG_HTML_CSS_OUTSTREAM, cssStream);
			props.put(APIConst.TAG_HTML_EXPORT_PATH, exportDir);
			

			//set result type as html format.
			//html result filenames is 
			//"temp_name*.*".
			//html result files include temp_name.css, temp_name_*.html etc.
			props.put(APIConst.TAG_RESULT_TYPE, String.valueOf(APIConst.HTML));

			System.out.println("========to html="+props);

			String tempResult = server.runReport("admin", catalog, rptName, props);
			cssStream.close();
			htmlStream.close();
			
			out.print(htmlStream.toString());
			System.out.println("========tempResult="+tempResult);
		
		%>
      </div></td>
  </tr>
  <tr>
    <td colspan="2"><table width="100%"  border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td height="1" bgcolor="#9F9F9F" style="border-bottom:1px solid #DFDFDF; "><img name="" src="" width="1" height="1" alt=""></td>
      </tr>
    </table>
      <table width="100%"  border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td height="22" class="small">&copy; Copyright 2009 Jinfonet Software, Inc. All rights reserved.</td>
        </tr>
      </table></td>
  </tr>
</table>
</body>
</html>
