Archive for the ‘java’ Category

Apache Tomcat Tshirt

Thursday, July 9th, 2009

Some time back I created a tomcat tshirt. I never got to print it out but here’s the pic if you need it yourself..!

tomcat Click to Enlarge

Gone are the days of EJB

Sunday, January 18th, 2009

I hated EJB. I still hate it and will keep hating it. Perhaps its not just hatred but its apathy. Be it EJB 1.x , 2.x or 3.x.  Frameworks come and frameworks go and I don’t feel EJB has survived with respect to the hype it received. I would discuss some major points which get EJB lagging behind:

Too many diversified versions: For those of you who have been with EJB since 1 or 2 would probably agree how it vagabond the versions were. EJB. I once heard Debu Panda from Oracle saying : EJB 1 was like a Queen Honey Bee – Lot of Hype  but did nothing. EJB 2.x came out like an Elephant: Like a mammoth, It could do a lot many stuff but eating away a lot of resources too! Then came EJB 3.x which is like a COW who is much productive and minimal resources.

But the big question is : You still need to write a lot of code! EJB is just not available in the student community. There are quite a few books, but they are industry oriented or rather useless.

Talk of the industry: When I used to take sessions for EJB for young industry guys. I get bombarded with questions on how I could help them use EJB to solve their problems!

Come on guys, EJB is OK but you don’t have to use EJB all the time!!  Its like old days of 90’s when XML was very popuar and people just used XML with every second application! Give me a break!

Fine lets talk about enterprise now as EJB’s E stands for Enterprise. EJB’s model definitely gives you a lot of stuff for the enterprise framework but it surely takes all your resources – Manpower, Infrastructure and mostly contunity. EJB makes you lame. Once you have implemented a lot of things in EJB its quite difficult to move out of it. I hate you EJB for that.  Many of my blog readers are avid Oracle and EJB fans, but sorry guys but EJB has #FAIL ed.

Competition: With EJB 3.x standing still, we have a lot many competing technologies at our hand. EAI frameworks like WebMethods, TIBCO and Kettle (Open Source) gives you far better implementation and reduce overall costs.
Another such framework which has not got the fame it should get is DWR – Direct Web Remoting. TIBCO sponsors this project and its a MUST try out.

The only thing I like about EJB is the persistence API but when things get complex, not many people can do a great job with it. So eventually they still end up doing more stuff.

Overall, I still hate EJB and feel it should reach its end of life!

html2pdf using jsp and linux

Thursday, January 15th, 2009

Have you ever thought of downloading the current viewed page as PDF. Here’a  quick program which can read an HTML and convert it to PDF using JSP or Servlet. I am going to call an external linux command called ‘convert’ which does all the magic for me.

All I need is a linux box with ImageMagick setup along with html2ps and ghostscript. I can get this very very easily from my ubuntu’s apt-get install …

So here’s the small snippet which I wrote after setting up.

try
{
Runtime rt = Runtime.getRuntime() ;
Process p = rt.exec(“convert /usr/local/share/pdfformat1.html /usr/local/share/pdfformat.pdf”  ) ;
p.waitFor();   //<– This waits until the operation is over
System.out.println(p.exitValue());  //<– if the output is 0 it means pdf was generated successfully
}
catch (Exception e){
e.printStackTrace();
}

Now this can be quite a good replacement for iText html to pdf conversion which is quite buggy (I am a huge fan of iText, but somehow this HTML needs to be rendered properly I feel)

After having got the file, read the file and reply to your browser by response.setContentType(“application/pdf”);

Please note, ONLY valid HTML tags are allowed. This method doesn’t support CSS. If someone knows of it, please let me know.This method works perfectly well with valid HTML syntax. So if your output pdf isn’t looking as expected, please check your HTML.

You can use this little utility to check your valid HTML #: sudo apt-get install wdg-html-validator and then run #: validate filename.html
This will list out all the invalid HTML tags.

So for all you report building guys out there, here’s a quick tip: Just output your report as HTML <offcourse with data poluated> and then use this utility to generate a PDF out of it!