DirectorySoftwareBlog Details for " my programming log debug enabled"

my programming log debug enabled

my programming log debug enabled
My notes as i code, I am a Java programmer mostly write web applications.

Articles

Installation Wiki
2008-01-24 21:57:00
InstallationWiki is a lesser known site but I find it very useful to troubleshoots my installation issue.
More About: Alla
Accessing remote Linux UI from windows
2008-01-24 21:34:00
Sometime you need to access UI of the remote *nix platform from windows machine, I need this quite often for testing my standalone Java swing application.Download Xming and install.Open ${xming_home}/X0.hosts file, add the IP of your linux box, this works like xhost config on *nix.Restart Xming from system tray.set the DISPLAY to your PC, e.g. for bash shell use cmd: export DISPLAY=${my_pc_ip}:0.0run your GUI command on the shell
More About: Windows , Linux , Remote
Fun programming
2007-09-19 20:07:00
There are some programmer like me who code for money but there are few who just love programming. I would debate the wastage of such good programming brains for these useless programs, but i love them and I admire them. Have a look at 99 bottles of beer my favorite is this one elegantly written in perl, and have a look at this one in Java (satire). By the way if you have some free time try this         ;   
More About: Programming
Developer tools for browser
2007-09-19 19:55:00
Firefox developer tools: Web developer and Firebug Internet Explorer Tools : IE Developer ToolbarI think these are must for webapp developer, very useful in debugging. Web developer for Firefox is really Firefox version of IE Developer Toolbar. I specially like the Inspect feature for those nasty UI issues.
More About: Browser , Browse
Multiple Profiles using firefox
2007-09-19 19:41:00
Ever faced this situation, you are logged into your gmail, yahoo, orkut, hotmail etc. One of your friends came up to you and want to check his/her gmail,yahoo,orkut etc. You need to log out, I know its quite irritating. But thats where multiple profile feature of firefox come to rescue, you can use following command.firefox -no-remote -pcreate a new profile for your friend and you don't need to logout.This is also useful when you are developing web application and need to loging as multiple users to complete one usecase. I generally update my desktop firefox shortcut with above.
More About: Firefox , Profiles , Profil
weirdo NULL handling in SQL
2007-08-18 14:51:00
Conisder following SQL statementSELECT * FROM sometable WHERE num 1;If you expected this to return rows where value of num is null, then you are wrong. SimilarlySELECT * FROM sometable WHERE LENGTH(my_col) < 20 above will not return rows with my_col having null values.This is bcoz SQL don't consider null as a value and since null is not a value it cannot be compared with a value. This is the diffrence between Null and either 0 (zero) or an empty string (a string value with a length of zero, represented in SQL as '' ). While null indicates the absence of any value, the empty string and numerical zero both represent actual values. So be careful while you are writing "less than" or "not equal to" queries on nullable column.Got some more time read this on wikipedia.
javax.net.ssl.SSLHandshakeException
2007-08-18 14:38:00
If you see collowing exception, while accessing HTTPS URL from java code.javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException : No trusted certificate foundThen most likely the URL you are accessing doesn't have certificate signed by a CA, and you need to install this certificate manually. Use keytool to import the certificate to a keystore (lets name this as mykeystore and you put this in /etc/keystoers dir) and then start your java application with following parameter -Djavax.net.ssl.trustStore=/etc/keystores /mykeystore.
Hibernate: Computed property value
2007-08-18 14:00:00
Many times you want to have computed value from db as a property value of an entity. For simple computation, where you additional information from DB is not needed, you use java code which is fine. But if you need information from DB, it means additional queries. Hibernate provides a powerful feature known as as derived propertiesFor example consider there is are table called Order and OrderItem; an Order has multiple OrderItem(s) and OrderItem has a field called price. Now if you want orderPrice property in Order Entity such thatorderPrice = sum of all OrderItem.price*OrderItem.qty where OrderItem.orderId=<my order id>.This can be done simply by defining a property in hbm file like this .< property name="orderPrice"formula="( SELECT SUM (OI.QTY*OI.PRICE) FROM ORDER_ITEM OI OI.ORDER_ID = ID )"/>These properties are by definition read-only, and the value is computed at load time. You declare the computation as a SQL expression, this translates to a SELECT clause subquery...
More About: Property , Prop , Pert , Rope
Ant javac: Unknow source in stacktrace
2007-08-18 12:52:00
I,Nidhi and Kush at mChek were debugging some code and got following exceptionException in thread ... java.lang.ClassCastException at SearchCustomerAction.search(Unknown Source )Some googling helped and we found the reason. It was obvious that Java compiler didn't generate the debugging information. But why? I thought I had not provided any extra javac parameters, and by default javac should generates debugging information (it actually generates line number and source file information by default, local variable information is not generated by default). So wats wrong?Actually we had used Ant for our build and javac Ant task by default doesn't generate debugging information. So the debug flag need to be turned "on" explicitly, something like this:<!-- build.xml --><project name="someProjectName" default="build" basedir="."> <target name="build"> <javac srcdir="." destdir="." debug="on"/> </target></project> For more information see javac and ...
AJAX response: HTML, XML, JSON
2007-08-04 19:33:00
Its fun to have the partially refreshing dynamically modifiable page using AJAX, both for application developer and for application user. But as a application developer parsing the partial response from server and dynamically modifying the DOM can become very complicated, parsing the response itself can be very tedious. Though the 'X' in AJAX stands for XML but your response need not be XML, it could be any text format, for our discussion we consider following three text response typesHTML/plaintextXMLJSONIf you just need to modify one section of page and can use the response as is, then its no-brainer, you simply use HTML or plain text response. e.g. if you build expand collapse control where you want to display some information in a div/span you just get processed HTML from server and use it as follows in you onreadystatechange event handler:var expandAreaDiv= document.getElementById("expandAreaDiv"); expandAreaDiv.innerHTML=text;But life is not this simple always :-). As you app...
More About: Ajax , Html , Response
html checkbox submitting unchecked value
2007-08-03 21:14:00
If you have used checkbox you would know that the checkbox value get submitted with form only if checkbox is checked, this is required by w3 html spec . What if you want to know if a checkbox was already checked when page was rendered and now unchecked by user. Specially if you are using a framework like struts and want to set a value in ActionForm based on checkbox value. Try submitting the form using Java script<form name=myForm action="http://debugtrue.blogspot.com/fee ds/posts/something.do" ><input type=checkbox name=mycheckbox value=test />...Your normal form code here...<div/><input type=button name='submitMyForm' value='submitMyForm'></form>func tion submitMyForm(){ var hiddenArea = document.getElementById("hiddenArea"); var myCbx = document.myForm.mycheckbox; if(!mCbx.checked){ var hiddenStr = "<input type=hidden name=mycheckbox value=notest />"; hiddenArea.innerHTML =hiddenStr; } document.myForm.submit;}
More About: Html
Array: new vs. java.lang.reflect.Array.newInstance
2007-08-03 20:41:00
Since i was writing about array I thought this is also worth mentioning.There are two ways of creating arrayString str[] = new String[4];String str[] = (String[]) java.lang.reflect.Array .newInstance(Strin g, 4);Both are same, you use second one where you can't use the first i.e. you don't know the type of array in advance.
More About: Java
Lets discuss Array Typecasting
2007-08-03 19:33:00
You would think this code should work:Object[] objs = new Object[2];objs[0]="Hello";objs[1]="World" ;String[] strs = (Str[]) Objs;// print the array..Code compiles fine, but when you run it, you get java.lang.ClassCastException. And you start wondering why? String is subclass of Object so its not narrow conversion then why do i get ClassCastException. I tried to find answer on net but could not find, so below is just my own logic (disclaimer :-) )String extends Object fine, but String[] doesn't extend Object[] both of them extend Object, in short they are not in hierarchy so you get ClassCastException. Lets look into more detailLets try System.out.println(strs.getClass()); which prints --> [Ljava.lang.Stringand System.out.println(obj.getClass()); prints --> [Ljava.lang.Objectonly common thing is [L, what is this?Class Type that defines an Object consist of two things ClassType and ComponentType. For all array objects class name is same i.e. [L, but component types differs. Which im...
More About: Array
Primary Key vs. Unique Key
2007-07-29 12:56:00
There are two differences between Prim ary key and Unique Key:First and a trivial difference is that Unique Key would permit null value (one null value per cloum in the unique key constraint), while Primary key would not allow for null value.Second and the major difference that you should know is that the Unique Key indexes are non-clustered while Primary key is clustered index. This difference has following corollariesThere could be only one PK per table emanating from the fact that there could be only one clustered index on a table.The PK affects how the data is physically stored but a unique key doesn't.Now the question is what is a clustered index and why there can be only one clustered index on a table. Clustered index is a index with leaf node containing actual data and not pointer to the actual data while for Unique Key index, leaf node contains pointer to the actual data storage.
HTTP Head method
2007-07-29 10:50:00
HTTP HEAD request is similar to HTTP GET request except that the Server will not send and response body in response to the request. e.g. if you make a HEAD request to resource /image/test.jpg, server will send only the response status to the client (200 if the image exists) the actual image will not be transmitted to the client. This is useful in cases where you are referring an external resource and not sure if a resource exists on server or not. Or you want to know if you have access to certain resource on server, or ever if you just want to know when the resource on the server was last modified.The HEAD request can be very useful specially with AJAX calls.
More About: Head , Http , Method
Reversing words in a String
2007-07-29 10:28:00
This I think is by far most popular string Interview question, be it on Java/C/C++ or C#Question : Write procedure to reverse the words in a String , assume words are separated by blank-spaces e.g. given a string "Writing and debugging software", the output of the procedure should be "software debugging and Writing"Here is the code which i had written recently in Java, i think the code and algorithm is self-explanatory, but if you need help understanding the code please let me know.If you have a big string and don't like the idea of O(n) space complexity and want to do it in O(1) space, than instead of putting words in word and to_ret arrays, you just store the array indexes and as soon as you find a blank space shift the original array up by the last word length and add the word to appropriate position in the string. This is just a hint i'll leave the implementation to you.. I can send you the code, if needed. public class Reverse { public static String reverse(String str) { ...
More About: Words , Tring
Printing session attributes and request attributes in JSP for debugging
2007-07-29 10:06:00
I generally like to use following JSP which I call req_session_attribute_printer.jsp for debugging purpose. I just include this jsp, where ever i want to debug, i have found this very useful over time for simple debugging.<%--req_session_attribute_pr inter.jspAuthor:<a href="mailto:get.anurag at gmail do com">Anurag Kumar Jain</a>Date: July 25, 2007--%><%@ page language="java" contentType="text/html; "%><script type="text/javascript">function showHideAttributes(spanId){ if(document.getElementById(spanId).style. display=='block'){ document.getElementById(spanId).style.dis play='none'; }else if(document.getElementById(spanId).style. display=='none'){ document.getElementById(spanId).style.dis play='block'; } }</script><a href="#"> Attributes</a><span>Session Attributes:<% java.util.Enumeration salist = session.getAttributeNames(); while(salist.hasMoreElements()){ String name=(S...
More About: Request , Printing , Debugging , Utes
IE Caching issue with AJAX HTTP GET request
2007-07-29 09:57:00
There is one very annoying issue with IE using AJAX when you use a HTTP-GET request (I haven't faced this problem with HTTP-POST request). I tried following but nothing seemed to work:response.setHeader("Cache-Control"," no-cache"); //HTTP 1.1response.setHeader("Pragma","no-cache" ); //HTTP 1.0response.setDateHeader ("Expires", 0); //prevents caching at the proxy serverSo we need to fool IE to consider the request as new request everytime, and you can fool IE by adding current timestamp at the end of your url. You can do following in your Javascript code:url= url+"?currDate="+ new Date(); if your url is simple like /test/something.doORurl= url+"&currDate="+ new Date(); if your url contains request parameters and looks something like /test/something.do?id=1234
More About: Caching , Request , Ajax , Http , Issue
Hibernate Reverse engineering tool
2007-07-29 09:51:00
May time you want to reverse engineer the Hibernate definitions from already existing scheme. Hibernate tools with Ecliplse plutgin is a very useful for this purpose, more information here on hibernate.org.
More About: Engineering , Tool , Erin , Reverse Engineering
Creating your own ajax loading image
2007-07-29 09:49:00
I found this useful for creating images for my AJAX loading ICONs http://www.ajaxload.info/
More About: Creating , Ajax , Image , Loading
Enabling Expression Language (EL) in JSP
2007-07-29 09:44:00
You can do it in two ways:Enable it for whole application : Put following in web.xml<jsp-config><jsp-property -group><url-pattern>*.jsp</ur l-pattern><el-ignored>false</ el-ignored></jsp-property-group> </jsp-config>Enable it for just one JSP page : put following at top of your JSP Page<%@ page isELIgnored="false" %>Make sure when you use the first option you use 2.4 schema or above. i. e. your root tag in web .xml looks something like this.< web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSche ma-instance" xsi:schemaLocation="http://java.sun.com/x ml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2 _4.xsd" version="2.4">make sure you are using Jasper jars for JSP 2.0 or above.
More About: Language , Expression
AndroMDA: Generating create/drop schema script with Maven 2
2007-07-29 08:39:00
First of all I would recommend anyone who is using the anroMDA for first time to read${application_root}/readme.txt file carefully. This helps understanding the generated schema.If you read readme.txt, you will notice two tasksmvn -f core/pom.xml andromdapp:schema -Dtasks=create --> generates the DDL create code and subsequently tells the database to create the schema for the entitiesmvn -f core/pom.xml andromdapp:schema -Dtasks=drop --> generates the DDL drop code and subsequently tells the database to drop the schema for the entitiesmvn -f core/pom.xml andromdapp:schema -Dtasks=drop,createBut wait, these target don't seem to work for me if i use maven-2 (mvn) with AndroMDA 3.2.add following to the plugin configuration in core/pom.xml<executescripts>false&l t;/executescripts><tasks>create& lt;/tasks><tasks>drop</tasks& gt;and now when you run the above targets, the create and drop DDLs are generated in the path specified by createOutputPath and dropOutputPa...
More About: Script , Maven , Create , Drop , Chem
Remote and Local EJB with AndroMDA
2007-07-29 08:38:00
@andromda.ejb.viewType "both" isn't supported, that's the reason. If you want to use remote at all, then set it to "remote", most application servers (like JBoss) treat remote interfaces as local when they're in the same JVM anyway.
More About: Local , Remote , Mote , Loca
Understanding Java Security and permission
2007-07-29 08:26:00
This is a must read for any java programmer, combined with this article on Java World
More About: Security , Permission , Understanding , Missi
Installing AndroMDA plugin for Maven 2
2007-06-04 10:52:00
Click here to download the the AndroMDA plugin installer.Unzip the contents of the installer into your Maven repository at C:Documents and Settingsyour user name.m2 epository.Verify that the following directory was created: C:Documents and Settingsyour user name.m2 epositoryorgandromdamavenpluginsandromda- maven-pluginCreate a temporary directory, e.g. C:andromda-temp.Create a file called pom.xml in this directory with the following content.<project> <modelVersion>4.0.0</modelVersio n> <groupId>samples.test</groupId&g t; <artifactId>test</artifactId> <version>1.0</version> <packaging>jar</packaging> <name>test</name> <build> <defaultGoal>compile</defaultGoa l> <plugins> <plugin> <groupId>org.andromda.maven.plugins </groupId> <artifactId>andromdapp-maven-plug.. .
More About: Plugin
ibiblio maven repository 301 eorror
2007-01-02 19:29:00
I was getting following errorError retreiving artifact from [http://www.ibiblio.org/maven java.io.IOException: Unknown error downloading; status code was 301public maven repository on ibiblio was moved to a mirror site. This is indicated by HTTP response status 301, which indicates file is permanently moved. Maven 1.0.2 do not seem to understand redirect.Solution: Add http://mirrors.ibiblio.org/pub/mirrors/ma ven to the list of remote repositories in project.properties in addition to the original entry (http://www.ibiblio.org/maven).For Maven 2, this should not cause any problem, as you can specify mirrors in settings.xml. For more details see the following link: http://maven.apache.org/guides/mini/guide -mirror-settings.html
111738 blogs in the directory.
Statistics resets every week.


Contact | About
© Blog Toplist 2012 - Supported by Web Catalog - SEO by FeWorks
eXTReMe Tracker