Category: Java

Cool Messenger Libraries for Developers

I have been planning to develop a localized messenger service for Bangladeshi peoples for quite a long time. I studied a lot on this topic and many times attempted to kick start the development, but unfortunately I ran out of time every time. But what I found is a wide range of libraries available for developers to develop such a service without spending a great amount of time. Let me list some of them here for You

1. Wildfire IM Server with IM Gateway [Java]
2. sendMsg [PHP For MSN (The Best)]
3. MSNP [PHP for MSN]
4. Joscar [Java for AOL/ICQ]
5. jYMSG[Java For YM]
6. TjMSNLib [Java for MSN]
7. Java-Jml [Java for MSN]

Are you interested????

Managing dynamic form elements in Struts

Those who are working with Struts, it could be a great problem if you have dynamic form elements in your form and you need to manage them. As they are dynamic, you dont know what are their name and you ant actually map these properties into your ActionForm bean. So how to manage these dynamic form elements, any idea? Take a look at this solution below.

First, Lets make your ActionForm bean like this

public class TestBean extends ActionForm {

public final Map values = new HashMap();

public void setValue(String key, Object value)
{
values.put(key, value);
}

public Object getValue(String key)
{
return values.get(key);
}
}

here comes the action in struts-config

Now we need to see how we can map dynamic properties in JSP pages.

Submit This

Please note that we add “value()” – thus it will access the Setter method setValue() in our ActionForm bean.

Finally, lets capture the submitted dynamic values in our Struts Action

public class TestAction extends Action {
public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {

TestBean tb = (TestBean) actionForm;
httpServletRequest.setAttribute(“dynamic”, tb.getValue(“dynamic”)); //first dynamic
httpServletRequest.setAttribute(“dynamic2”, tb.getValue(“dynamic2”)); //second dynamic
return actionMapping.findForward(“success”);
}
}

Well, you can just go thru the HashMap in TestBean for all the dynamic values.

Using XOM API for parsing XML

XOM api is a fantastic wrapper over apache xerces. XOM is very memory efficient. If you read an entire document into memory, XOM uses as little memory as possible. More importantly, XOM allows you to filter documents as they’re built so you don’t have to build the parts of the tree you aren’t interested in. For instance, you can skip building text nodes that only represent boundary white space, if such white space is not significant in your application. You can even process a document piece by piece and throw away each piece when you’re done with it. XOM has been used to process documents that are gigabytes in size.

You will find some cool examples here

Veni Vidi Vici

It is a famous Latin phrase coined by Roman general and consul Julius Caesar which means “I came, I see, I conquer”. He announced to the Senate after his victory over Pharnaces. Well, I just finish another huge task in my desktop – Probably I am also happy as Caesar right now.

Yesterday it was full of learning and new achievements. I converted my existing database into HSQL and it was a big one, 62337 rows sized approximately 9MB. Some days ago hasan told me that HSQL is a nice embedded db solution for java, and he was right. After I examine the HSQL db I found that it stores data as plain SQL entries. Still it is so fast.

I complete the integrated spellchecker for nobobangla, a realtime help and two dictionary in java. spellchecker was a great task and I enjoy the whole work. Now it is much efficient than the previous one.

One more thing I found while working with Base64 encoding in Java. The jakarta commons package codec seems a bit confusing and I could not manage it to work as expected. It generates non compliant base 64 – I didnt know why. Well, then I found teh following routine is extremely useful for encoding – take a look at the following example

import sun.misc.BASE64Encoder;
public class Test {
    public static void main(String[] args)
    {
        BASE64Encoder b = new BASE64Encoder();
        System.out.print(b.encode("hasin".getBytes()));
    }
}

————————————————————–
disce quasi semper victurus vive quasi cras moriturus