I have been in the business of Software Development for around 4 years. I got a chance to try my hands on lots of technologies. I would like to share with you some of my findings which might prove useful to you.
Compare two XML files

As XML becomes the standard for integrating applications, it has become necessary to be able to perform various operations on XML. Usually, SAX and DOM parsers from open source communities help you fetch the data from the XML. However, there is no standard tool available which can help you compare two xml files and present output in correct format. Usually, most tools compare xmls but give inconsistent results if the order of the nodes is different. For example, you can try using http://compare.deltaxml.com to compare the two files test1.xml and test2.xml . Now if we compare the same two xmls using our algorithm, our output is test.xml which you should try to compare with the output from delta xml that you obtained earlier. You can download the code from this link http://cityhaat.com or http://dheerendraitbhu.blogspot.com/

Convert HTML to PDF
Please have a look at this tool HTML TO PDF I used this tool in one of my projects where I needed to convert some/all of the content displayed on-screen to PDF format by clicking on a button in the page.

Javascript to print preview a page
Copy and paste the following contents in a new html page. Also observe the use of @media tags which you can use to specify what to show on screen and what to send to the printer.



Java E-mail Regular Expression Checker Pattern
private static Pattern emailPattern=Pattern.compile("^[a-zA-Z][\\w\\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\\w\\.-]*[a-zA-Z0-9]\\.[a-zA-Z][a-zA-Z\\.]*[a-zA-Z]$");
//This will return true or false for an e-mail expression
emailPattern.matcher("[email protected]").matches();

JTable Sorter
If you have ever programmed in Swing, you will realize the intricacies in changing the components.
This link "Sorting a JTable" gives a really good example of how to achieve this. They have also provided TableSorter Just use the following lines in your code and see the magic:


TableSorter sorter = new TableSorter(new MyTableModel()); //ADDED THIS
//JTable table = new JTable(new MyTableModel()); //OLD
JTable table = new JTable(sorter); //NEW
sorter.setTableHeader(table.getTableHeader()); //ADDED THIS

XSL Template to Convert the mantissa-exponential format to long format
It so happened that I had to format a number given in mantissa-exponential using format-number. You might be aware of the fact that xsl format-number cant be used directly to format a number given in mantissa-exponential format. It could have always been done if the formatting had been done from the back-end. However, I took it as an experiment to test my XSL skills. Also, it felt great to use a recursive routine to accomplish this, otherwise trivial task.



SCP to a remote machine without specifying password
Normally, you use FTP/SCP to send data files from one machine to another. However, SCP is different from FTP in a way that in case of SCP the data sent along the wires is encrypted while in FTP it isnt.
Quite often, you would like to automate the process of SCP which doesnt require any manual intervention. To accomplish this, follow these steps:
1. Generate SSH2 public/private keys. ssh-keygen -t rsa (accept filename / path) (you may return twice for password)
2. Secure copy public key to your remote machine. scp ~/.ssh/id_rsa.pub remotemachine:~/.
3. Touch authorized_keys2 file on remote machine to either create it if it doesn't already exist or to simply update its timestamp if it does exist. ssh remotemachine "touch ~/.ssh/authorized_keys2"
4. Append your public key to the authorized_keys2 file on the remote machine. ssh remotemachine "cat ~/id_rsa.pub >> ~/.ssh/authorized_keys2"
5. Set the **required permissions on the authorized_keys2 file. ssh remotemachine "chmod 644 ~/.ssh/authorized_keys2"
6.scp -Cp $DIR/$FILE.tgz $USER@$SCPSERVER:~/.

Automate the build process by polling the CVS repository for changes
When the number of classes and the number of developers in a project increases substantially, there are frequent build failures in projects(which you would certainly not like to happen!!). CRUISE CONTROL is one such tool that I tried recently and found it to be really interesting.
What CruiseControl does is no rocket science but its very easy to configure and set up, thats why so popular.It polls the CVS repository for a project spcified in a config.xml file at frequent intervals which is configurable again. If it finds that there is a change in files that it has on the local machine by comparing with the ones checked into the CVS, it starts a build process by specifying a build-yourproject.xml file for an ant task. E-mail notifications can be sent once the build process is finished,specifying a url which contains a few good-looking charts depicting the status and time when the build was made, as well as logs of builds. Have a look at this document which I followed step by step STEPS.The summary of steps on WinXP (JDK 1.5.1,Ant 1.5.3-1)is:
1)Download CruiseControl.zip
2)Extract it in a folder INS_DIR on your machine.
3)Edit your PATH environment variable so that INS_DIR\main\bin lies in the PATH
4)Create a WORK_DIR on your local machine.Create folders as:
(i)WORK_DIR/artifacts/YOUR_PROJ_NAME
(ii)WORK_DIR/logs/YOUR_PROJ_NAME
(iii)WORK_DIR/checkout/YOUR_PROJ_NAME
5)Edit your PATH environment variable so that WinCVS\CVSNT lies in the PATH. Just enter cvs on cmd console to see if you get usage details in the messages displayed which means CVS is in the PATH.
6)Checkout your project from CVS into the WORK_DIR/checkout folder.
7)Create config.xml in WORK_DIR


8)Create a file WORK_DIR/build-YOUR_PROJ_NAME.xml .Observe that this is the filename you specified in the config.xml above which will be executed once the changes have been found and build has to be made.


9)If you now run cruise from your WORK_DIR by running cruisecontrol.bat, you should see cruise start. Now the main job is done and we only need to set up notifications now.
10)Installing CRUISE CONTROl webApp.
a) Open the "INSTALL_DIR/reporting/jsp" directory.
b) Create a new file called "override.properties", the properties in this file will be used to generate the Web.xml (deployment descriptor) for the web app. The file should look like this:

c) Generate cruisecontrol.war by executing "build.sh war" or "build.bat war" in the directory INSTALL_DIR/reporting/jsp.
d) Deploy the generated web application "INSTALL_DIR/reporting/jsp/dist/cruisecontrol.war" to your application server, and browse to APPLICATION_PATH/index.jsp. This page provides links to the buildresults page for each project (good for multi-project configurations).
I encountered a slight problem here when I clicked on the link specified in the config.xml as it printed a stack trace showing some servlet exception while applying XML Transform. So, I removed the servlet.jar for the APPLICATION_PATH/WEB-INF/lib and it started working after that. The document whose link I have mentioned states that you need to remove xalan.jar and xerces.jar while building. I am sure you guys are intelligent enuf to try out all permutations and combinations which will make the link work as you would hate to let things go wrong after all the hard work you have done so far.



Open a URL using a Java Program and read the contents
Download the program from here.

HOME
Hosted by www.Geocities.ws

1