April 1, 2009

Echo2: Turn Java into AJAX Without Touching JavaScript or JSP

he web is experiencing a rapid trend towards AJAX and rich Internet applications (RIAs). With AJAX as a tool for RIAs, developers can now deliver much richer content over the web and produce much more sophisticated user experiences. At the same time, a lot of frameworks that hide the inherent

Destroy a Java Logger using the contextDestroyed Method

public void contextDestroyed(ServletContextEvent e) { //get the servlet context ServletContext servletContext = e.getServletContext(); //get the real path String root = servletContext.getRealPath(“/”); //get all handlers Handler[] handlers = logger.getHandlers(); //remove all handlers for(int i = 0; i &lt handlers.length; i++) { logger.removeHandler(handlers[i]); handlers[i].close(); } //delele all the files related to the

Function to Extract a Regular Expression Pattern From a String

The following function returns the part of the passed string that matches the regular expression provided. You can use this function to get the necessary data from fields in a form, etc. The function takes three parameters: the string to validate, the regular expression, and the grouping pattern that you

Be Careful of Negative Array Indices

While porting a 32-bit application to a 64-bit version, I discovered an interesting effect. The original code used negative array indexes frequently, which worked fine on a 32-bit machine, but caused some horrible results on a 64-bit machine. This tip explains the problem: Many books that discuss negative array indices