• Enter Slide 1 Title Here

    This is slide 1 description. Go to Edit HTML of your blogger blog. Find these sentences. You can replace these sentences with your own words.

  • Enter Slide 2 Title Here

    This is slide 2 description. Go to Edit HTML of your blogger blog. Find these sentences. You can replace these sentences with your own words.

  • Enter Slide 3 Title Here

    This is slide 3 description. Go to Edit HTML of your blogger blog. Find these sentences. You can replace these sentences with your own words.

Wednesday, October 15, 2008

Unable to load dynamic library php_curl.dll: Error message in PHP

PHP logoIn Windows, while trying to use "curl" extension with PHP 5.2/Apache 2; you may encounter a blank page. If you open up the error log file in Apache (%APACHE_HOME%\logs\error.log); you may see an error message as follows.

"PHP Warning: PHP Startup: Unable to load dynamic library '%PHP_HOME\\ext\\php_curl.dll' - The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log for more detail."

This error message can be caused due to some version conflicts on a set of DLLs that are already available inside %windows%\system32 directory.

First check the %windows%\system32 directory to see whether the following DLL files are already available.
curl logo
  1. libeay32.dll
  2. ssleay32.dll
If those are available, then you would be able to resolve the issue as follows. (However if they are not available, you would need to find some alternative solution).

Now you must first rename the above two DLL files. We did as follows by adding an .old extesion.
  1. libeay32.dll.old
  2. ssleay32.dll.old
Both these libeay32.dll and ssleay32.dll files are available inside your %PHP_HOME% directory. Now copy both of those DLL files into %windows%\system32 folder.

Now try to use the "curl" extension, and it will start to function properly. (Sometimes you may need to restart Windows).

However if this tip could not resolve your issue, make sure to restore the previous DLLs.

Manage HTTP headers with Java Servlets: Quick Notes

Servlet & JSPIn Java Servlets API, both HttpServletRequest and HttpServletResponse interfaces (in javax.servlet.http package) provide methods to programatically manipulate HTTP headers. There are a number of standard HTTP headers exchanged between a web server and a client (eg: a browser). "Content-Type" is a commonly used header (which is used to specify MIME type) in Servlets. In this article we are discussing how headers are read/written with Servlet classes.

Reading Headers

A servlet can read HTTP headers sent by a client request using HttpServletRequest interface. This interface has two methods for this.

String getHeader(String headerName)
int getintHeader(String headerName)

Both these methods are similar except getIntHeader() method is used to return value of headers with int type values. Below code shows how value of "User-Agent" header is read from the user request. (HttpServlet.doGet() method is used in the example).


import javax.servlet.http.*;
import java.io.*;

public class MyServlet extends HttpServlet {
public void doGet(re, res) throws IOException{
String contentType = request.getHeader("Content-type");
....
}
}

Creating/Writing Headers

A servlet can create a header and send back to the client using HttpServletResponse interface; using the following setter methods.

void setHeader(String headerName, String headerValue)
int setintHeader(String headerName, int headerValue)

Below code shows how a new header named "My_Header" is created and set on response.


import javax.servlet.http.*;
import java.io.*;

public class MyServlet extends HttpServlet {
public void doGet(re, res) throws IOException{
response.setHeader("My_Header", "new Header value");
....
}
}

Now the client (generally the browser) will receive this new header.

Wednesday, October 8, 2008

Google redirect to incorrect country domain: Fix on Firefox

Google servers identify the country of the googler and redirect to the relevant country domain. They may be using the IP of the request to locate the country before the redirect. However there are situations many googler getting redirected to incorrect country domains. For example, even though our requests are generating from Sri Lanka, most of the time we are redirected to another country (Taiwan) domain. Some misconfigurations at the routers or at the ISP may cause this issue, which makes it harder for a general browser user to get that resolved. This automatic redirect mechanism does not depend on the browser used.

Following is a quick fix to this issue. However this will only work on Firefox browser, sorry friends if you are on another browser.

Install Redirector extension

Redirector is a small extension available for Firefox, and it supports most of the versions ranging from 2.0 to 3.0.*. (we are using latest Firefox; 3.0.3). You can freely install it from here.
If you are a newbie to Firefox extensions; just click the "Add to Firefox" button in the web page and click "Install now" in the pop up box. You must restart Firefox, to complete this installation.

Now you will see a small icon in status bar (bottom right corner) as shown here. This is the redirector extension we installed above. You can enable/disable this extension just by clicking on this icon.

Configure a redirect

Right clicking on that Redirect icon will display a settings panel. Click "Add.." button to add a new redirect.

Now we have to fill 3 options in this new redirect box.

1). Include Pattern: Here you must try the incorrect Google country domain url. As our incorrect country domain is Taiwan, we set the following as "Include Pattern".
http://www.google.com.tw/*

2). Redirect to: This is the place where you specify the correct country domain url. As we live in Sri Lanka, following is the redirect url for us.
http://www.google.lk/$1

3). Pattern Type: Set this to "Wildcard".

It's done, quite simple. Now the Redirect settings box will look somewhat similar to the above image.

Now try and load Google home page, and it will display the country domain home page you set in the redirect settings.

Tuesday, September 23, 2008

Gmail Multiple Sessions Alert: This account is open in 1 other location

Gmail This account is open in 1 other location"This account is open in 1 other location at..." Gmail user interface provides this message when your account is used in multiple locations simultaneously. One of the most important and interesting security feature that any web mail service would wish to provide. I suppose Gmail is the only web mail service that has this type of security feature (let us know if any other does). Users become aware of any misuse of their Gmail accounts.

Gmail is countering the number of active sessions per account in providing this information; so "open in multiple locations" means that there are multiple active session for this particular account. Gmail also provides more details about each session making it easy to track the misuser. Access Type, IP address and Date/Time are displayed as details.

Effectiveness

All these details are visible to all web sessions including misuser's session; so the effectiveness of this feature is in doubt. For example, a misuser can sign out as soon as this information is displayed in Gmail account. However a solution for this will not be simple and easy. In the meantime, these information is not displayed in a very prominent place (shown at the very bottom of the page), only the misuser will use these information rather than actual (innocent) account owner.

Improvements

Gmail Top Links BarWe are not highlighting the weaknesses by neglecting effort made in providing this feature. However, as an improvement; active sessions count can be shown at the top bar; so that all users will notice the multiple session usage. However this should be displayed only when multiple sessions are active.

Tuesday, September 16, 2008

Sun suspends NetBeans IDE DVD Starter Kit distribution program

Sun has suspended their NetBeans IDE DVD Starter Kit distribution program indefinitely. Yes, you read it correctly; they have done it. So many developers used to get most of Sun (free) products through the distribution program. Students with less bandwidth (in some colleges & universities); specially users without Internet access to home computers are fond of this service as NetBeans DVDs are freely delivered to their hands at no cost.

According to NetBeans.org;
"Since August 30th, 2005, NetBeans.org has shipped more than 225,000 CDs & DVDs to developers around the world through this initiative! During this period, NetBeans has experienced explosive growth as a download, media kit, and a community. To stay ahead of this encouraging trend we are looking into ways to effectively satisfy increasing demand for NetBeans software worldwide."

For sure this service played a huge role in helping so many Java developers. Also the program is a good marketing option for NetBeans since Eclipse (the best free Java IDE) provides no such services, rather than allowing free download. Sun also has decided to follow the same; stick only for free downloads. However the Starter Kit is available for download as an ISO image. In near future may offer downloads via mirrors and bit torrent; but not sure how near that future is. Anyway we are grateful to service Sun provided us.

Tuesday, September 9, 2008

Lazy loading vs. pre-loading beans with Spring Framework

Spring LogoSpring framework can instantiate and bind (called loading) related Java objects (called beans) according to a given configuration. An XML file can easily be used to define these bindings. Spring framework supports two different types of loading methods; lazy loading and pre-loading respectively managed by BeanFactory and ApplicationContext containers.

Lazy Loading

A bean is loaded only when an instance of that Java class is requested by any other method or a class. org.springframework.beans.factory.BeanFactory (and subclasses) container loads beans lazily. Following code snippet demonstrate lazy loading, concentrate on how "beans.xml" spring configuration file is loaded by BeanFactory container class.

BeanFactory factory =
new XmlBeanFactory(
new InputStreamResource(
new FileInputStream("beans.xml")));// 1
Employee emp = (Employee) factory.getBean("employeeBean");// 2
Even though "beans.xml" configuration file is loaded with BeanFactory container in line number 1, none of the beans will be instantiated. Instantiation takes place only at line number 2, where bean called "employeeBean" is requested from container. Since the class is instantiated at getBean() method call, time spend to return this method will vary depending on the instantiated object.

Pre-loading

All beans are instantiated as soon as the spring configuration is loaded by a container. org.springframework.context.ApplicationContext container follows pre-loading methodology.

ApplicationContext context =
new ClassPathXmlApplicationContext("beans.xml"); 1
Employee emp = (Employee) context.getBean("employeeBean"); // 2
As all singleton beans are instantiated by container at line number 1, this line will take some considerable time to complete. However line number 2 will return the bean instance immediately since instances are already available inside the container.

Point to note

Decision to choose one from these two methods would depend solely on application specific requirements. Some applications need to load as soon as possible while many others would probably willing to spend more time at startup but serve client requests faster. However some of the beans defined in a configuration may only be used rarely, so instantiating such classes at start up would not be a wise decision. Similarly, some Java instances would be highly resource consuming; leading not to instantiate at start up.

Related articles

[Eclipse] Access restriction: Class is not accessible due to restriction on required library

"Access restriction: Class is not accessible due to restriction on required library"; error message may be shown while developing Java projects in Eclipse IDE. Error message is self-explanatory, some classes can not be loaded into the project since restriction rules are being imposed on those classes.

How to solve

This error message can be removed by changing a setting inside Eclipse IDE. Open up the dialog box shown below, using any of the following paths.
  • Windows -> Preferences -> Java -> Compiler -> Errors/Warnings
  • (Project) Properties -> Java Compiler -> Errors/Warnings
Locate the "Forbidden reference (access rules)" option under "Deprecated and restricted API" section in the dialog box. This option decides how to handle access rules defined inside Eclipse. By default it is set to "Error" which causes Eclipse to complain about references to any restricted classes. Choosing any other option (Warning or Ignore) will remove these error messages.

"Warning" or "Ignore" options will only hide the potential issue in the project, by allowing the project to use any classes ignoring predefined access rules. To completely resolve this issue, analyze the project and located the use of restricted classes and take necessary actions (either remove those references or access rules).

Related Articles

Thursday, September 4, 2008

Chrome or Firefox - which browser to choose?

Chrome is the newest baby in browser family or the next competitor in browser war. What ever it is, Google released their browser named Chrome. But Mozilla Firefox is the most popular browser in the world right now and Google was the major supporter for Firefox. Even while supporting it, they have built their own browser free and open source. Here we are looking at the two browsers and trying to compare them to decide whether to switch to the new one or not leaving our old but fascinating friend Firefox?

Interesting features

1. One Process per each tab
Tab is not another thread running inside the browser process; there is a separate process per tab. Even if one tab crashes, the rest of the tabs will be running as nothing happened; which was not available in Firefox. This is one of the most interesting features.

2. New tab is filled with useful links
For a new tab in Firefox, you can load a predefined page, a blank page or a predefined set of page links (using an extension). But you would be much happier to see a set of links that you dealt with in recent past; Chrome comes exactly with that. The new tab will show a set of links;
  • Most visited pages
  • Recently closed
  • Recently Bookmarked
I do not think the last one will be much useful, but the other two will be pretty handy.

3. Rich Location bar
Location bar in Chrome is a combination of location bar & search bar. You can directly type a url or a search keyword, also it comes with suggestions.
Using separate location bar per each tab is also an interesting move, each tab looks like individual browser instances; while in firefox you have single location bar shared by all tabs.

4. Speed
Stephen Shankland at CNet has posted an article on speed, and it tells most of the details. However Brendan at MozillaZine has published another set of testing statistics. So we'll have to check some statistics done by an independent party to get a clear view. Anyway Chrome is starting up so fast compared to any other browser.

Some complains

Since Chrome is still in beta, this may be a good time to suggest some features or improvements. Following are some complains that we have.

1. No warning in closing
When multiple tabs are opened Firefox is used to show a warning in closing the browser, but Chrome does not and closes immediately. Since people can accidentally close the browser better to add it soon.

2. Displaying different fonts
Some of the fonts are not displayed smoothly as Firefox used to do. Above image shows how the same content is displayed in two of these browsers.

3. No XML viewer
May be it is not a must to have a XML viewer in a browser, but we are used to it. Firefox and IE both have good XML viewers, but Chrome lacks it. Similar to this Opera and Safari also do not have this feature. Many people happened to work with XML files every day and having an XML viewer in the browser is an added advantage.

4. Security issues
Chrome has exposed to a set of known security issues by using an older version of WebKit, which had already been fixed. Anyway we expect Google to fix it soon.

Main Concern

Above all of these our main concern is the lack of support for extension development. We are used to live with some great extensions with Firefox, which we are not experiencing with Chrome. Since it is still in beta version, we should wait for extension support. However no API is released for extension development, users will have to wait longer than expected to see some useful extensions. There are so many extensions that makes our lives easier and better. Few of them are;
  • NoScrip
  • Adblock
  • Gmail Manager
What are the other reasons that you are not switching to Chrome straightaway?

Wednesday, September 3, 2008

Use "object" instead of "bean" in Spring Configuration XML

Spring configuration xml is used for defining the wiring between different object. It has the following format.


<beans>
<bean id=".." class="...">
...
</bean>
...
<beans>
Classes specified in the configuration file will be instantiated by Spring container. And those objects will be bound with each other accordingly. Any java class specified under attribute named "class" will be instantiated. There is no much limitations on the classes that can be used for this here. It does not need to be a JavaBean. It can be any POJO (plan old java object). The only requirement is that this class must be possible to instantiate.

Spring LogoSo why does this tags are named <beans> and <bean>? This seems to be misleading.

In Spring one way of binding objects is using the beaness of java classes. But that is not that only way to bind them together, constructor can be used to bind objects. So if configuration file used tags as follows, it would be more meaningful.

<objects>
<object id=".." class="...">
...
</object>
...
<objects>

Seems it is used only to express that beaness can also be used in initialization. Would you agree? May be we are not seeing the exact reason. This is completely open for discussion.

Related Articles

Tuesday, September 2, 2008

Google Web Toolkit (GWT) & Servlets - Web application tutorial

GWT LogoGoogle Web Toolkit (GWT) and Java Servlets used in one web application. This tutorial will take you though the steps of developing a simple web application with Google Web Toolkit and J2EE Servlet Technology. The application will have a servlet on server side and one web page.

Prerequisites

  • Better to be familiar with developing web applications with J2EE/Servlets
  • Knowledge on deploying a web application into Tomcat web server

System Requirements

  • JDK installed
  • Apache Tomcat web server (download, any other web server can be used)
  • GWT (download)
In brief, GWT is a framework for developing Ajax based web pages with Java. All the HTML page content will be written as Java classes and converted into a set of Javascript files. For more information on GWT, refer to official site here. http://code.google.com/webtoolkit/

Introduction

In this tutorial we will create a simple web application which has one page. When a user clicks a button, web page content will be updated without refreshing or leaving the current page. But the web page will talk to a servlet deployed in web server and update the page content. The communication between web server and browser will be invisible to the user, providing a convenient web experience. Even though this is a simple application, it represents a main concept of any advanced application implemented with GWT.

Implementation

The development work is broken down into 7 steps and each will be discussed in details.
  1. Create a java web project with GWT
  2. Data Service - server & client side
  3. Widget (component displayed on web page)
  4. Entry point
  5. Web page (html/jsp)
  6. Module XML
  7. Compile and deploy
In this document $GWT_HOME is used to denote the directory where extracted GWT framework is available.
eg: $GWT_HOME=C:\java\gwt-windows-1.4.61

1. Create a java web project with GWT

To start with, we need to create a java project. GWT comes with a script to create a java project according to the recommended project structure. It is called "applicationCreator"; applicationCreator.cmd is available inside $GWT_HOME directory.

$GWT_HOME> applicationCreator -out C:/samples/GWT-Sample 
org.kamal.hello.client.HelloWorld

For parameter named "out" you must provide the location to create the new project. Also a class name must be provided for this command. This class is called Entry point class (we'll be touching this class later).
Above command creates a project named GWT-Sample in the destination location and created project would look as follows.

GWT applicationCreator project structureIt will contain a Java class (Entry point class), a HTML page and a XML file (called Module XML). This module xml file will also be discussed later. For the time, better note the path to this file: org/kamal/hello/HelloWorld.gwt.xml.

2. Data Service - server & client side

For our application we need a service that provides data for our client side page. So we'll define this service to have only one method returning a String. This service will be provided through a servlet which is running on a server side. Generally we would write only a single servlet that extends from javax.servlet.http.HttpServlet, but in GWT we must define two interfaces inside client package (org.kamal.hello.client) along with the servlet. However these two interfaces are quite simple.

i). Service interface

The services provided by the server-side must be declared in a Service interface first. The methods declared in the Service interface will be available to the client side. It is only a simple interface which must extend com.google.gwt.user.client.rpc.RemoteService interface. We will define the service interface with only one method that returns a string.

package org.kamal.hello.client;

import com.google.gwt.user.client.rpc.RemoteService;

public interface DataService extends RemoteService {
public String getData();
}

ii). Asynchronous Service interface

Next we will define another interface called "Asynchronous interface". This interface is used to define the asynchronous feature of the service. That is when ever a call is made to this interface, the caller can expect the service to be asynchronous and the result will be available after sometime. The caller must provide a callback object to receive the resulting data. There are some important points to note.
  1. Asynchronous interface must be in the same package as the service interface
  2. This interface's name must be as <Service-Interface-Name>Async (same name with Async suffix)
  3. Add a new parameter of type com.google.gwt.user.client.rpc.AsyncCallback to parameter list of every method.
  4. All methods must have void as return type
package org.kamal.hello.client;

import com.google.gwt.user.client.rpc.AsyncCallback;

public interface DataServiceAsync {
public void getData(AsyncCallback callback);
}

The above interface is named DataServiceAsync (using DataService + Async) and the DataService.getData() method is provided with a new parameter while having void return type.

iii). Service servlet

Now we can define the service servlet which does the actual work. This class must implement above declared DataService interface and extend the com.google.gwt.user.server.rpc.RemoteServiceServlet class.

package org.kamal.hello.server;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import java.util.*;
import org.kamal.hello.client.DataService;

public class DataServiceImpl
extends RemoteServiceServlet implements DataService {

public String getData() {
int key = (int)(Math.random()*3);
return (String)data.get(String.valueOf(key));
}

private static Map data = new HashMap();

static {
data.put("0", "Hi, This is Server");
data.put("1", "How are you?");
data.put("2", "It’s too warm here at Server");
}
}

Above class implements the getData() method of DataService interface and returns a String with simple logic. Even though we call this a servlet, no servlet specific implementation is available, so is this a servlet? Yes, it is; the super class, RemoteServiceServlet is a servlet.

iv). Servlet configuration (web.xml)

Now we have to specify the servlet in a web.xml file. (Do not worry even if you are not much familiar with web.xml, everything needed is listed below).

Create a file named web.xml inside GWT-Sample project folder with the following content.

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<servlet>
<servlet-name>DataService</servlet-name>
<servlet-class>
org.kamal.hello.server.DataServiceImpl
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>DataService</servlet-name>
<url-pattern>
/org.kamal.hello.HelloWorld/data
</url-pattern>
</servlet-mapping>
</web-app>

Here we have defined a url pattern for our above mentioned DataServiceImpl servlet. Note the way this url pattern (/org.kamal.hello.HelloWorld/data) is defined.
First part of the url pattern org.kamal.hello.HelloWorld is derived from the path to Module XML file which is org/kamal/hello/HelloWorld.gwt.xml. The rest of the url pattern can be selected arbitrarily, better to use a declarative word.

3. Widget (component displayed on web page)

Now we must create the widget that will be displayed in the web page of our web application. The widget coding is listed below.

package org.kamal.hello.client.widgets;

import com.google.gwt.core.client.*;
import com.google.gwt.user.client.rpc.*;
import com.google.gwt.user.client.ui.*;
import org.kamal.hello.client.*;

public class HelloWidget extends Composite {

public HelloWidget() {
// obtain a reference to the service
service = (DataServiceAsync) GWT.create(DataService.class);
ServiceDefTarget endpoint = (ServiceDefTarget) service;
endpoint.setServiceEntryPoint(GWT.getModuleBaseURL() + "data");

initWidget(panel);
panel.add(label, DockPanel.CENTER);
panel.add(button, DockPanel.SOUTH);

// click listener to get data from server
button.addClickListener(new ButtonClickListener());
}

private class ButtonClickListener implements ClickListener {
public void onClick(Widget sender) {
// call servlet to get data
service.getData(new AsyncCallback() {

public void onFailure(Throwable e) {
label.setText("Server call failed");
}
public void onSuccess(Object obj) {
if (obj != null) {
label.setText(obj.toString());
} else {
label.setText("Server call returned nothing");
}
}
});
}
}

private final DataServiceAsync service;
private final DockPanel panel = new DockPanel();
private final Button button = new Button("Talk");
private final Label label = new Label("Welcome, talk to server");
}

This widget contains one label and one button. It uses a reference of type DataServiceAsync to communicate with the DataServiceImpl servlet deployed on a web server. You must pay attention to the way this DataServiceAsync reference is obtained.
HelloWidget.ButtonClickListener class is there to respond to onClick() action of the button. Inside this class an implementation of AsyncCallback is used to get data from the DataServiceAsync reference and to update the label content.

4. Entry point

Entry point class was generated while creating the project at step 1 of this tutorial with the class name org.kamal.hello.client.HelloWorld. This is the class used to load the widget into the web page. Inside the onModuleLoad() method, we have accessed an element named "content"; this element must present in the web page that we are expecting to load the widget. Then the HelloWidget; the widget we created above is added into this element.

package org.kamal.hello.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;
import org.kamal.hello.client.widgets.HelloWidget;

public class HelloWorld implements EntryPoint {

public void onModuleLoad() {
// set widget on "content" element
RootPanel content = RootPanel.get("content");
if (content != null) {
content.add(new HelloWidget());
}
}
}

5. Web page

Following is the page that we will be using to load our HelloWidget. This page is already available inside GWT-Sample1\src\org\kamal\hello\public folder. Edit this page to have the following coding.
This page contains an element with id="content", which is used to load the newly created widget into this page. Also note that a .js file has been imported into this page. We will be generating this org.kamal.hello.HelloWorld.nocache.js file in a following step.

<html>
<head>
<title>HelloWorld</title>
<script language="javascript"
src="org.kamal.hello.HelloWorld.nocache.js">
</script>
</head>
<body>
<h1>HelloWorld</h1>
<table align="center" width="100%">
<tr>
<td id="content"></td>
</tr>
</table>
</body>
</html>

6. Module XML

This is the module configuration (module xml) file. The entry point class is specified in this module xml. This file is also autogenerated in step 1, and it is stored inside "org\kamal\hello" folder.

<module>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name="com.google.gwt.user.User" />

<!-- Specify the app entry point class. -->
<entry-point class="org.kamal.hello.client.HelloWorld" />
</module>

7. Compile and deploy

We have created all the required classes and files. Now we must generate Javascripts from above created Java classes. Then compile and deploy the project.

i). Generate Javascript from Java classes

For generating Javascript files from Java classes we will use the HelloWorld-compile.cmd, which was generated into the project folder in the step 1. You just have to run this command file without any parameters.

GWT-Sample> HelloWorld-compile.cmd

This will create a new folder named "www" inside GWT-Sample project folder, and it will contain a set of web resources including "org.kamal.hello.HelloWorld.nocache.js" file which we used in step 5.

ii). Compile classes

Now create a folder named "WEB-INF" inside "www" folder. Then create two folders named "classes" and "lib" inside this WEB-INF folder.
Now compile service related Java classes that we created up to now into this www/WEB-INF/classes folder.

GWT-Sample\src> javac -cp $GWT-HOME/gwt-user.jar 
-d ../www/WEB-INF/classes
org/kamal/hello/client/Data*.java
org/kamal/hello/server/*.java

Now copy $GWT-HOME/gwt-servlet.jar file into the www/WEB-INF/lib folder.

GWT-Sample> copy $GWT-HOME\gwt-servlet.jar www\WEB-INF\lib

Note: we use gwt-user.jar to compile while gwt-servlet.jar at deployment. (you can read the reason here).

Copy GWT-Sample/web.xml into www/WEB-INF folder.

iii). Deploy into web server


GWT web application deployed in TomcatCreate a folder named "GWT-Sample" inside $CATALINA_HOME/webapps and copy "www\org.kamal.hello.HelloWorld" and "www\WEB-INF" folders into that "GWT-Sample" folder (shown above). Now everything is completed.

Start Tomcat and try the following URL from your browser.
http://localhost:8080/GWT-Sample/org.kamal.hello.HelloWorld/HelloWorld.html

GWT HelloWorld web application outputNow you will see the web page with the label text and button as shown in the image. Play around by clicking the button to see different messages coming from the server. The web page will not be re-fetched from the web server, but only the text of the label will be refreshed.

Even though this is a pretty simple application, you can use this concept to develop advanced applications.

Wednesday, August 27, 2008

Is Partitioning a hard disk into multiple drives bad?

Hard Disk drives partitioning and accessing speedHard disk partitioning is almost a must, according to what I have heard so far from my colleagues and other professionals (may be same for you). I am used to partition a hard disk at least to three drives; "C" for OS (Operating System), "D" for programs and "E for other files like documents, archives. But I got a chance to read some material on hard drive performance and it completely argued my partitioning practices.

When considering the speed in reading a file from hard drive following are two important points related to partitioning.

1. Files in outer tracks are readable much faster
It is a well known theory in hard disk read/writes that performance is much higher in outer tracks compared to inner tracks.

2. When partitioning a hard disk, the first partition is created in the outer tracks
In creating partitions, the first partition is created in the outer most tracks while each new partition is created in inner tracks than the previous. So the partitions in a hard disk would look as the above diagram.

These two are important point to consider. We are creating partitions in order to organize the files according to mentally created categories; like operating system in one partition while program files in another partition. But I did not organize the files in the frequency they are used (which I should have thought of). There are some files frequently used, but placed in different drives without knowing this speed factor. For example; some java projects are stored in drive "E" which I happened to use daily.

So what are the solutions we can think of, in order to achieve the best performance of the hard disk considering these facts? I can think of following two solutions.

1. Create only one partition
One option would be to refrain from creating more than one partition and storing all the files in there. Then we would have to store the most frequently used files in outer tracks while hardly used ones in inner tracks. However this is not that possible, since user is not deciding the location of a file when saving into hard drive. The only solution will be to use a defragmenting software to organize the files later according to the accessing frequency.

2. Store files on partitions according to the frequency of use
We would create a set of partitions same as we used to do earlier, but with a different intension. Files will not be saved in each drive depending on the type or categories, but according to the frequency. The most frequently used files will be stored in drive C while least used files in Drive E. But then again, memorizing the file locations will not be easy.

What is the method are you using in your computers? Do you have any experience in above mentioned suggestions? We welcome your ideas and experiences or any other suggestions.