Monday, March 30, 2009

Getting a machine's HostName from an IP Address

If you ever need to find the host name for an IP address, use this:


nbtstat -a address


That will give you the host name of an IP Address.

Directory Mapping in Tomcat 6 / 5.5

For those of u who have always wanted to map a directory and not a servlet in Tomcat, here is how to do it:
1. First in your web.xml - edit the < listings > tag as follows:
< init-param >
< param-name > listings < / param-name >
< param-value > true < / param-value >
< / init-param >


2. Then ensure that under the conf folder in your Tomcat directory, you have the following virtual directory (for Tomcat 6):
conf -> Catalina -> localhost

The above directories will already exist in Tocat 5.5, so all you need to do i carry on Step 3.

3. create a file called media.xml and save it in the localhost folder. Also, put the following content into this folder:

< !--
Context configuration file for the Tomcat Manager Web App
$Id: resources.xml 303123 2004-08-26 17:03:35z remm $
-- >

< Context path="/media" docBase="D:/Importer/Media" debug="0" privileged="true" >
< / Context >


With this media.xml file, if you type in http://localhost/media, it will get mapped to the D:/Importer/Media
Setting the < listings > tag causes the directory structure within D:/Importer/Media to be displayed.

JavascriptException with Gwt Maps 1.0.3 (using GWT 1.5.3)

I had a google MapWidget that has several marker overlays. When run
in hosted mode, these markers can be seen. However, once compiled into
Javascript, the following error is thrown in Firefox:

Error: [Exception... "'com.google.gwt.core.client.JavaScriptException:
(TypeError): a is null
fileName: http://maps.google.com/intl/en_ALL/mapfiles/150c/maps2.api/main.js
lineNumber: 532
stack: (null,"C:\\myIcon.png",[object Object])@http://maps.google.com/
intl/en_ALL/mapfiles/150c/maps2.api/main.js:532
("C:\\mtIcon.png")@http://maps.google.com/intl/en_ALL/mapfiles/150c/
maps2.api/main.js:1262
l2([object Object])@http://localhost:8080/MyProject/
ACADCA4DA4C0B465E1EA03342F4CF5CC.cache.html:726
C1([object Object],[object Object])@http://localhost:8080/MyProject/
ACADCA4DA4C0B465E1EA03342F4CF5CC.cache.html:710
mx([object Object],[object Object])@http://localhost:8080/MyProject/
ACADCA4DA4C0B465E1EA03342F4CF5CC.cache.html:154
px([object Object])@http://localhost:8080/MyProject/
ACADCA4DA4C0B465E1EA03342F4CF5CC.cache.html:156
([object Event])@http://localhost:8080/MyProject/
ACADCA4DA4C0B465E1EA03342F4CF5CC.cache.html:204
' when calling method: [nsIDOMEventListener::handleEvent]" nsresult:
"0x8057001c (NS_ERROR_XPC_JS_THREW_JS_OBJECT)" location: ""
data: no]

Hence, in both Firefox and IE, I couldn't seem to see the markers.

The reason for this is my use of absolute paths rather than relative paths. Ensure that the marker's icon is not on an external absolute URL. The markers I was using used an icon from C:\MyIcon.png. When this is deployed as a war file in Firefox and IE, the marker's icon src was null as it could not point to that URL in web mode. Solution: Ensure that the icon is
in the 'public' folder in your project. Eg. My images are in the 'public/images' folder and hence the icon's url is:
Icon icon = Icon.newInstance("images/MyIcon.png");

This will be visible in webmode when deployed using a war file.