Monday, September 7, 2015

Declarative Exception handling in struts


Declarative programming is a way to separate Control from computation logic . Exception handling in java is usually done using try catch and throws . In jsp we can handle exceptions using errorPage attribute of page declarative . Any exception occurred will be routed to the value of errorPage attribute . In addition to this struts offer similar way of handling exception . Use exception tags in StrutsConfig.xml to declare excpetion handling . All exception tags should be enclosed under global-Exception tag. Type of exception is mentioned in type attribute , exception message is mentioned in key attribute and the page which is called in case of exception is mentioned in path attribute of exception tag . The action exception message is picked from MessageResource.properties file for the key in key attribute .

Wednesday, August 26, 2015

Advice in spring


Advice is the action taken up by an Aspect at a join point . You can use a specific advice based when you want it to be executed . Before Advice : If you want your advice to be executed before the join point use Before Advice .

Monday, August 24, 2015

Hashcode in java

What is the use of hashcode in java.
Hashcode is very important in java . in object class , you will have a method hashcode , which will give the hashcode of an object.

hashcode is used to check whether two objects are equal or not . If two objects have a different hashcode they are definately not equal , but if their hashcode is same ,it does not guarantee both objects to be same .

hibernate pooling


what is hibernate pooling ?

aspect in spring


Aspect is modulerization of a concern that cuts accross multiple classes . Take an example of exception handling ,consider exception handling as an Aspect . In a program if an exception occurs it is an example join point as per spring nomenclature . At a join point action taken by Aspect is called an Advice , so if an ExceptionHandlingAspect calls logException(Exception e) ,logException is an example of advice . All advices has a pointcut expression , if for a join point , point cut expression is true , then the advice is executed at the join point .

Sorting list contents

List content is sorted using Collections.sort(listObject,comparatorObject);
For example if have list of Student object and you want to sort it, then you need to create a new object of type Comparator. The logic of comparision is written in

int compare(Object object1,Object object2)

While overriding compare method you need to return the following :
Positive integer : if object 1 > object 2
Negative integer : if object 2> object 1
Zero : if object 1 = object 2

This logic will allow your list to be sorted in ascending order.

Tuesday, May 5, 2015

Public key private key certificate

public key is the one which is shared , l can share my public key to you . Suppose you want to send a document to me .So you can encrypt it using a public key . Once it reaches me I can decrypt it using a private key . If the document is delivered to an unknown person he cannot decrypt it since he does not have the private key .

ec2-user@ec2 Permission denied