Friday, April 13, 2012

Ear comparator


Many Occasions, we might end up with comparing two ear/war files in our project for some reasons. Here is the link for EAR comparator utility (Good stuff Joseph! – The mastermind behind this tool). You may think it will be good if you have some utility to compare such circumstances.

I have link below for ear files comparator utility. I strongly recommend this tool to make your job easier. 


Anymore suggestions? Drop those in comments section.

Cheers,
-NjN

Sunday, April 8, 2012

To start work with Maven (more than a build and deploy tool)


So far I have used ant as a build tool in all my projects. When I recently gone through the articles, found Maven used widely in most of the Java/J2EE applications. I tried to install maven in my machine recently. But found many issues and it was very difficult to follow the setup to complete my very first build.

I have found an excellent material to work with Maven. It has step by step guide with the screen prints. I found the below link is very interesting to follow. Hope this will useful to you as well.


Friday, April 6, 2012

How to work with browser specific Style sheets

If you would have worked with web applications I am sure you might had difficult time to deal with applying the style sheets specific to browser and its’ version.
Have found nice information on applying the browser specific style sheets recently.  Wanted to share with you guys.
Below article explains very well on conditional based approach (browser & version) to apply the different CSS files. This is most commonly used approach as well. 

CSS cross browser selector comes with noticeable approach, where we no need to write different CSS files. Within the same CSS file we can mention the style classes based on the brower&version.

The second will be most preferable if we have css file with lesser contents. What do you think?

Monday, March 19, 2012

Java Anti Patterns:


I had gone through core java design patterns last week (I am sure I will consolidate my learning with simple examples and post you in my blog. I will try to keep as much as my own examples).

We have a proverb in our native language that “If you wanna become good doctor, you should have killed 100+ patients”. What they try to say here is if we want to give the best, we should have experience/come across as many nastiest.  

So, before I start my Java design patterns, I had gone through few Java Anti patterns which are readily available in the internet. I found the below link gives you Insite on Java Anti patterns. Hope you enjoy as well.

Please share me if you find any good link for Java Anti patterns.

http://www.odi.ch/prog/design/newbies.php

Friday, March 2, 2012

To get the newly stored record auto generated key (primary key) with in hibernate


I have seen few hibernate (ORM framework) codes have always uses saveOrUpdate method to create a record newly or to update the existing records. Most of the occasions, we were dam sure that a new record is gonna insert. Such occasions, we can use save method itself. No harm.  

Here I am going to discuss some peculiar scenario where we may need to get the primary key of the newly added record to send as a response to UI.

For Example, I am capturing required employee details and creating a new Employee record. Usually we used to display feedback as Info message in the screen stating “Employee record has been added successfully. as a response. Sometime we may need to display meaningful info message using the generated unique key for newly created record like “Employee record (1000001) has been added successfully.” Here, 1000001 is the primary of the newly inserted record.

To address the above requirement, I have seen few codes (mostly written by beginners), they used to call the save command (insert query) and use another select statement which gets you the recent record primary key column. It may work fine for the single user/thread environment. The same may not be true for multi thread environment. To address this issue in a multi threaded environment, below code may be useful for you to achieve the same.

Here, employeeObj is the hibernate object POJO for Employee Table. If we use hibernate save command, which will intern returns you the Serializable interface can cast to the primary key of the newly inserted record like below.  


//Plain Hibernate
Serializable t_pk  = t_session.save(employeeObj);

//Hibernate with Spring framework
Serializable t_pk  = getHibernateTemplate().save(employeeObj);


Long newEmployeeId = (long) t_pk  ;


Any thoughts? Please drop your comment.  


Cheers,
-NjN

Sunday, February 26, 2012

To read Window’s close button event using java script for application specific processing like session clear etc.


We are in very rapid technology transition world. Writing an application which is comparable to all the browsers and environments will be a tedious task for the developers like me.

Let me write a common & interesting issue with the web application session handling. While developing the web application, we will be clear about the scope of the variable to be used with in a web application (Like application, Session, Request and page scope etc). The entire logged in user specific details usually will be stored as session attributes. If we clear all session attributes, prior to closing the web application, its fine. No Harm. The same can be turned to be a headache if HttpSession was not handled properly. However if you use IE6, browser session automatically collected. In IE7, the same session will be used irrespective of the tabs opened within a browser instance. For IE8, same session will be used for all the browser/tab instances opened in a machine.

In a typical web application, we will be providing a Close/LogOff kind of buttons, so user could follow some basic process to exit the web application, using the button, we can handle the HttpSession. Also, we can’t assume that everyone would follow the process (It’s like turning off the PC. Sometimes we used to press the power button instead of shut down our PC). Now, the question is how can we handle, user session attributes such occasions as well.

Below example is self explanatory to address the above mentioned issue specifically for IE. Write to me if anything unclear.



Monday, February 20, 2012

Windows authentication using SingleSignOn within J2EE/.net application


Today I am going to write about Windows authentication using SingleSignOn method with-in j2EE and asp.net applications. Hope you will enjoy.

Consider the scenario where you are developing a web application, which can be used with-in an organization (Intranet environment) and also in Would Wide Web (Internet environment). Both the environments, application business logic would be. The only key difference would be, the authentication mechanism used among these two applications.

With in Internet environment, we may end up with displaying login page, where need to get the username and password from user and the same will to be validated in backend. Once authentication successful, we would be invoking application page.

Incase of Intranet environment, we know that the request is coming from trusted domain.  Hence we can go with Windows authentication using SingleSignOn option, to not to prompt username and password to login the application. Here, we can read the login username using windows shell script and set password can be set as some unique text and we can click the login submit button using java script. If request contains the password mentioned in html/jsp, we can consider request is intranet users, So we can consider the request as valid one, BUT we should check the username is correct and has correct privilege to access the application.

HTML code sample here explained for Windows authentication using SOO with in login page. Similar login page can be created for Internet application as well.  The only difference would be, we would be end u with calling setFocusForText java script mention in onload and anywhere with in th page.

<HTML>
<HEAD>
<TITLE> This is Windows authentication SOO testing TITLE>
HEAD>
<script type="text/javascript">
function setFocusForText() {
            document.getElementById("userNameText").focus();
            var wshShell = new ActiveXObject("wscript.shell");
            var userNameFromWin=wshShell.ExpandEnvironmentStrings("%username%");
            document.getElementById("userNameText").value=userNameFromWin;
            document.getElementById("passwordText").value="~~~~";
            document.getElementById("loginMe").click();
}
script>
<BODY onload="javascript:setFocusForText();">
<form id="loginForm" >
            <input type="text" id="userNameText" value=""/>
            <input type="password" id="passwordText" value="" />
            <input id="loginMe" value="Login" type="submit" />
form>
BODY>
HTML>


Do you think, hard coding the password with in html is venerable? If so, follow my previous blog to implement password encryption algorithm and store the same. And also, user can’t see the SSO page since it is kind of auto submit page. Page load would happen with in fraction of seconds.

Any other queries in your mind? Add it in comments section. Happy to respond to you. 

Pega Decisioning Consultant - Mission Test Quiz & Answers

The Pega Certified Decisioning Consultant (PCDC) certification is for professionals participating in the design and development of a Pega ...