Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 

Web applications with AnnotationConfigWebApplicationContext

Web applications with AnnotationConfigWebApplicationContext: In Spring we can use the WebApplicationInitializer in place of web.xml to initialize DispatcherServlet and use @EnableWebMvc annotation to support Spring MVC.The below example code can ...

Using context:component-scan to pick up @Configuration Classes

In Spring 3.0 using the tag context:component-scan in xml file, the entry of the class(or bean) defined under the scan tag is automatically created. The example to show use of context:component-scan tag is as below: Example:- JavaConfig.jav...

Instantiating the Spring container using AnnotationConfigApplicationContext

In Spring 3 we can also create a bean using java file instead of XML.It is alternate way to create the bean, you can also use xml based configuration. HelloWorld.java package com.babita; public class HelloWorld { public void p...

How to achieve Document Version Contorl in Liferay?

Liferay provides very rich environment to create versions for the Uploaded documents. You can achieve Document Version Control very easily in Liferay by using the below code. Create the object of ServiceContext as below: ServiceContext serv...

How to create XML File in Java using DOM parser?

To create XML file in Java,here we are using DOM parser. By using the below code you can easily create XML file. Write the below Java class to create a XML file: CreateXMLFile.java package com.babita; import java.io.File; import jav...

How to create CSV file in java?

Sometime we need to generate CSV from data as per requirement. You can easily create CSV file by following the below steps: Write the following Maven configuration in pom.xml file in your project: <dependency> <groupid>net....

How to read data from CSV file in Java?

Sometimes we need to read data from a CSV file as per requirement. You can easily read the data from CSV file by following the below steps: Write the following Maven configuration in pom.xml file in your project: <dependency> ...

Creating Custom Scope in Spring

Using Custom Scopes, we can define new scope as well as modify the existing scope. Custom Scope is useful for following scenarios- creating a bean scope where beans can be shared between servlet contexts creating a bean scope where bean...

Auto detect Components in Spring.

When we define the annotations @Component, @Service, @Repository, @Controller with classes, Spring automatically scan and identifies those classes and register the Bean definition with the ApplicationContext. The @Component annotations are: ...

@Resource annotaion in Spring

@Resource annotation allows you to specify a name of the injected bean. @Resource annotation takes a 'name' attribute which will be treated as the bean name we want to inject in the class. In other words we can say, it follows by-name autowiring ...

How to use Autowire With Qualifiers?

In Spring we use @Qualifier to indicate which bean we want to qualify to autowired on a field. when we create multiple beans of the same type( for example: Department) and want to autowire only one of them with a property in some other class (...

How to use Filters to Customize Scanning?

In Spring context XML file, Filter has a sub-element 'context:include-filter' having two attributes as 'type' and 'expression' attributes that indicate to Spring container that 'type' is of regular expression whose value is been provided by expre...

How to exclude a bean from auto-wiring?

When configuring beans in configuration file, set the "autowire-candidate" attribute of the bean element in .xml file to false, by doing this the container will exclude that specific bean from auto-wiring. By using the below example we can eas...

How to display location on Google Map in JSP in JAVA?

Sometimes we need to display Google Map on a JSP page, for this you just need pass lat/long to JSP. Use below code to initialize map in script: var marker = null; var map = null; var markers = []; function initial...

How to get aspect ratio of an Image in java?

Sometimes we need to get aspect ratio for an image in Java to fulfil our requirement. You can use the below code to get aspect ratio for an image in Java very easily: Define the dimension boundary of which you want resized image as below ( h...

Solution for MDM Error SIP-11008 and SIP-11141

If you are facing an error while executing batch for staging process in MDM Hub (Error executing job: SIP-11008, SIP-11141) Error Description : SIP-11008 :Failed running Cleanse: com.siperian.mrm.cleanse.api.CleanseException: SIP-11141: Excep...

Simple Image resizing example in Java

Sometimes we need to resize image in Java to fulfil our requirement. You can use the below code to resize image in Java very easily: Define the dimension boundary of which you want resized image as below Dimension boundary = new Dimensi...

Send Push Notification to iPhone device from Java Server Side

This blog will help you to send Push Notifications to iPhone devices from server side where server side code is written in Java. Follow the below code in order to send Push Notification: Define the below dependency in you pom.xml, if you...

Hadoop Mapper Utility Class

In example I am going to demonstrate how to load a file from Hadoop Distributed Cache. Here I am writing Mapper and Driver class, inside of Mapper class we have define input type key vale pairs and output type key value pairs. Inside driver c...

What is MDM?

MDM (Master Data Management), it has the object to provide data processing, data collection, matching information, data consolidation, data quality assuring and distribution data throughout organisation and have proper control on data maintenance...

Comparative Study on HashTable HashMap and HashSet

Hashtable This class has implemented Map interface, before using this data structure you should know their internal implementation Hashtable Class Decleration- <p>Public class Hashtable<k,v> implements Map<k,v> Yo...

Enumeration in Java

INTRODUCTION An enum type in Java is a special data type that is defined whenever you need to define a variable with a set of predefined values such as Days of the Week, Months of the Year, items in a menu, etc. KEY POINTS ABOUT ENUM ...

What is servlet ?

Servlet is very powerful server side scripting language. It is a class which basically handle network request-response model. It is very powerful as we had earlier like CGI. Basic Request-Rsponse Model When browser send http request to jav...

Multithreading in Java

Multithreading is the process of running two or more threads executing altogether within a single program in Java. Before understanding this let me first explain what threads exactly are. A thread is a light-weight process that runs independen...

Quartz +Spring Integration

It seems today every application needs background jobs, here we are going to learn how to integrate Quartz Scheduler with Spring. Version we are using Spring 3.x Quartz 1.8.6 Maven 3 we have to follow few steps for configure qua...

Marshalling and Unmarshalling in Java

JAXB is Java Architecture for XML Binding which allows to map Java objects to XML and XML to Java objects. Marshalling example : Converting a Java object into a XML file. import java.io.File; import javax.xml.bind.JAXBContext...

Calculate the distance between two locations through HQL in Java

Sometimes we need to calculate the distance between two locations. And to save the time of iteration we can get filtered results through query by apply functionality of calculating distance in the query. Suppose we have two tables Events and ...

Spring 3 MVC configuration.

Introduction to Spring 3 MVC Framework The Spring web MVC framework provides model-view-controller architecture and ready components that can be used to develop flexible and loosely coupled web applications. The MVC pattern allow us in separa...

Getting coming sunday from current date in Java

To get the coming Sunday from the current date or specified date, write the following code: public static Date getNearestWeekend(Date date) { try { Calendar c = Calendar.getInstance(); Calendar cal1 = Calendar.getInstan...

Getting distance between two locations by lat/long

You will get distance between two location easily by using below code. You will just need lat/long of both location for which you have to calculate distance. /** * Get distance of location between two locations * @param lat2 * @param lon...

Getting address and city from lot/long in Java

This blog will help you in getting geographical information of any location by using latitude/longitude. By using Java API Geocoder, it is easy to get geographical information of any location. The response will be in JSON or XML format. Wri...

Access restriction: not accessible due to restriction on required library

When i was working on a class i have got the following error.. Access restriction: The type BASE64Encoder is not accessible due to restriction on required library C:\Program Files\Java\jre6\lib\rt.jar I resolved it by looking up on google, ...

Getting weekends date in Java

To get weekend list for a current year, write the following code: private ArrayList weekendList = null; public void findWeekendsList() { weekendList = new ArrayList(); Calendar calendar = null; calendar = Calendar.getInstance(...

Polymorphism Java

Polymorphism in Java OOP's a very important jargon in the programming world, and many of us are familiar with this word, Object oriented Programming. Polymorphism is a main pillar of OOP,s by definition it is the ability of an object to t...

Getting ZipCode from lat/long in android

This blog will help you in getting geographical information of any location by using latitude/longitude. By using Java API Geocoder, it is easy to get geographical information of any location. The response will be in JSON or XML format. Wri...

Send Push Notification to Android Devices from Java Server Side

This blog will help you to send Push Notifications to Android devices from server side where server side code is written in Java. Follow the below steps in order to send Push Notification: Put the gcm-server.jar into your lib folder of y...

What is web.xml ?

web.xml is Deployment Descriptor which consist all the basic configuration servers( like Tomcat) need to know at the time of deployment like context path, url mapping, listener, filters, error and security. you can mentioned following in web.x...

Getting lat/long from ZipCode in Java

By using Java API Geocoder, it is easy to get geographical information of any location. The response will be in JSON or XML format. Write the following example to get Latitude/Longitude from Zip code: String postCode = "07001"; // you can u...

Amazon SES Client Mail Integration in Java

Using the Amazon SES SMTP Interface to Send Email To send email using the Amazon SES SMTP interface, you will need the following: An AWS account. For more information, see Signing up for AWS. The SMTP interface hostname and port number. ...

toString() in java

toString() method is very useful and frequently used by java developer. What is toString() ? As per java doc: 'toString() method returns the string representation of the object.' toString() method belongs to Object class, So each and every o...

How to Create Immutable Class in Java

How to create Immutable class in java Immutable class is a class which once created, its contents can not be changed. Immutable objects are the objects whose state can not be changed once constructed. e.g. String class Since the state of the ...

Hibernate environment in Spring

Spring comes with a family of data access frameworks that integrate with a variety of data access technologies. Whether youre persisting your data via direct JDBC, iBATIS, or an object relational mapping (ORM) framework such as Hibernate, Spring...

SSL By Pass

When we have a client/server application. There is certificate(SSL installed) in server side. So In that case we have a problem , how to extract data.In this case we can by pass the SSL just writing few lines of code. Write the below code b...

how to differentiate synchronized block and synchronized method in Java

The synchronization is the mechanism by which we can control multiple threads to access the shared resources. Without synchronization, it is possible for one thread to modify a shared resource while another thread is in the process of using or up...
1 2 3 5 next
Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: