• 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.