Thursday, October 8, 2009
Easy way to keep your Blog and Twitter up-to-date.
This is a redundant work which I have to do. Today when I was searching in the net found a cool web application which will update your twitter accounts if any update is made in your blogs.
The way it works is it takes your RSS feeds of your blog and understands the updates based on that it updates your twitter account.
twitterfeed
Then I added follow me on twitter in blog ;)
Try if you like it :)
Wednesday, October 7, 2009
How can we track from where user started to access your Web Application?
Referer Header Field:
This field in the header object will give you the web page URL from which you application was triggered.
Below code in java will give you the reference URL.
String refUrl = request.getHeader("referer");
Tuesday, October 6, 2009
Is there any difference between java.lang.NoClassDefFoundError and java.lang.ClassNotFoundException ?
When we started learning java most of time we may come across java.lang.ClassNotFoundException when we try to run some simple programs. Later we found that this error was throwing due to the class was not in the jvm class-path.
java.lang.NoClassDefFoundError will be thrown when the class was loaded and it cannot be initialized properly. As JVM can find the classes in the class-path and it cannot create a Class object of the class which is loaded.
Below are few scenarios where the class initializing may throw exception.
· When a exception was thrown inside the static block of the class.
o The reason is the static block is executed when the Class object is getting loaded, if any error occurs it can't be initialized.
· Any Exception was thrown when initialing a static variable of the class.
o The reason remains same as static block. It also getting executed during Class load.
Then the morel of the story is when the class was not properly initialized then we will get java.lang.NoClassDefFoundError, mainly due the static blocks and static variables.
Simple Example which will throw java.lang.NoClassDefFoundError..
package passionsoft.bloggerspot.com;
public class AnotherClass {
static String test = "new";
static AnotherClass staticObject = new AnotherClass();
public AnotherClass() {
String a = null;
a.length();
}
}
package passionsoft.bloggerspot.com;
public class SimpleTest {
public static void main(String[] args) {
AnotherClass a= null;
try {
a = AnotherClass.staticObject;
} catch (Error e) {
e.printStackTrace();
}
System.out.println(AnotherClass.test);
}
}
When SimpleTest calles the "AnotherClass.staticObject" the class get loaded and the static variable staticObject calles the constructor where the initialization failes… below is the error trace
java.lang.ExceptionInInitializerError
at passionsoft.bloggerspot.com.SimpleTest.main(SimpleTest.java:11)
Caused by: java.lang.NullPointerException
at passionsoft.bloggerspot.com.AnotherClass.<init>(AnotherClass.java:12)
at passionsoft.bloggerspot.com.AnotherClass.<clinit>(AnotherClass.java:7)
... 1 more
Exception in thread "main" java.lang.NoClassDefFoundError
at passionsoft.bloggerspot.com.SimpleTest.main(SimpleTest.java:19)
As per my understanding I can think only two scenarios when the java.lang.NoClassDefFoundError was thrown if you guys know some more scenarios please update the comments.:)
Monday, October 5, 2009
Great Add-ons for Mobile Testing
When you want to change your User-Agent name of your Browser (its nothing but your browser name which sent to the server on every request) you can use the "User Agent Switcher" Add-ons of Fire fox to change your user-agent....
What is the Special about Changing User-Agent?
The "User-Agent" is the only way (as of I know) the server come to know from which browser the user was triggered this request, based on that server may change its display logic...
If you try google.com from your mobile, you will see a different version as compared to your google.com from your web browser (IE or Mozilla), that difference. If you are a mobile developer want to know how the data are displayed for a Specific model you can give the user agent string of that Mobile then trigger the request.
For Example when you change your user-agent as "BlackBerry8800/4.2.1 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/100" and hit from you Fire-fox browser, the content will be displayed as it was seen in Blackberry 8800 Mobile…
These Very good Add-ons if you need to test with different mobile devices (as I do right now)…J.. Please feel free to add your comments ….
Monday, September 7, 2009
http://freelancefolder.com/
Sunday, September 6, 2009
Eclipse is here to Help You.
Better productivity with eclipse Part 01
Better productivity with eclipse Part 02
Please give your comments.
Friday, August 28, 2009
JavaRanch.com
Tuesday, August 11, 2009
Try HTML2ASCII convector Utility
Then i searched google and found a online HTML2ASCII convector Utility which really helped me :)
http://www.dynamicguru.com/tools/html.php
Try it you really find useful when you needed and bookmark it if you like...
Thanks a lot guys who was created this online tool :)
see you later
JSP Page encoding can’t be Dynamic?
<%@ page language="java" import="java.text.*" pageEncoding="UTF-8"%>
In above code snippets I was trying to inject the pageEncoding value as dynamic value (by using the evil Scriptlets) as below.
<%@ page language="java" import="java.text.*" pageEncoding="<%=pageEncodingString%>"%>
But Eclipse was shouting that it was not valid pageEncoding value.Then I realized that in @page attribute you can’t give a Scriptlets value… I am not sure is there any other way we can achieve this ? ….
I came to another way by searching google (as usual) , that nothing but adding a jsp-property-group attribute in
<jsp-config> <jsp-property-group> <url-pattern>*.jsp</url-pattern> <page-encoding>UTF-8</page-encoding> </jsp-property-group> </jsp-config>
You know how above code snippets work? It’s quite simple . You don’t need to add the pageEncoding="UTF-8" attributes in @page directive for all your Jsp files. If you make changes here it will affect all you jsp’s (based on your url-pattern).
Class : org.apache.jasper.compiler.JspConfig
But this also doen’t serve my purpose, the reason I have to change the encoding value which coming the Backend layer. I gone little bit further and found that there is some apache API to get the values of jsp-config in java class. When I saw that API I can find only the get methods and not the set methods. So again that doesn’t serve my purpose.
I still feel there should be some way to achieve this. If you guys have any thoughts please feel free post your replies here.
Finally welcome to my blog :)