Archive for December, 2008

report

I was creating a HTML Jasper Report. It was working fine, but I saw many failed images. When I see the source, I found many image tags like the following.

<img alt="" src="nullpx" style="width: 20px; height: 24px;"/>

When I googled, I found an image property need to be set to give the proper image name.

JRExporter exporter = new JRHtmlExporter();
...
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_WRITER,printWriter);
...
exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI,"image?image=");
....
exporter.exportReport();

I need to search whether we can avoid it. anyway this is a temporary solution. I created a servlet to create transparent empty GIF and called it over here.

folder

I was writing a servlet whose response is PDF, CSV, XLS etc. This works fine, but when I tried to save it HDD the url is given as the filename. I was wondering how to explicitly specify the filename. Here is the solution.

response.setHeader("Content-Disposition", "inline; filename=xyz.pdf" );

When we set this header property in the response, The filename will be xyz.pdf. Nice na!

PHP logo

I am thinking about this for long time. I am not able to write a single page in php. Today I did it. Just to share it with you :)

<?php
//title
$title = 'PHP Test';
?>
<html>
<head>
<title><?php echo "$title";?></title>
</head>
<body>
<?php
//create an array
$myArray = array('this', 'is', 'a', 'PHP', 'Test');
for ($i=0; $i<5; $i++)
{
echo "$myArray[$i]";
echo '<br>';
}
?>
</body>
</html>

Prints the following in the browser

this
is
a
PHP
Test

Nice! need to see the data types and database connectivity!