Struts, Spring, Hibernate… What next?

I have started my career in 2006 as a Java Developer. Since then most of the times I was being involved in developing web applications using Servlets, JSP, Struts, IBatis and Hibernate. In late 2008 I started working with Spring and now I am a big fan of Spring. I am pretty much interested in learning new technologies/frameworks. So i started playing with several things like Quartz, JMS, JSF,JasperReports, DWR, XStream API, JPA, JavaMail, DisplayTag, JUnit, Ant, ApachePOI, JExcel blah blah blah. I am very much bored of doing the same things over and over using Struts, Spring, Hibernate etc.

Continue reading »

JSF can be used for several purposes.

Recently I got a wonderful opportunity to work with JSF and I couldn’t stop myself sharing my feelings on JSF with everyone.By god’s grace till last month i didn’t a chance to work on JSF in my career. But recently i have to work on a project developed in JSF 1.x. After spending few days on JSF technology I realized that JSF is not only a web framework and we can use it for several purposes. Below is just a small list: 1. To test the patience and mental strength of a developer.2. If you are a team lead/manager and

Continue reading »

How to get List of property values from List of objects?

package com.javautils.core;import java.util.ArrayList;import java.util.Collection;import java.util.HashSet;import com.javautils.beans.Address;import com.javautils.beans.User;public class CollectionUtil{    public static void main(String[] args)    {        User user1 = new User(1,”AAAA”, “Hyd”);        User user2 = new User(2,”BBBB”, “Bnglr”);        User user3 = new User(3,”CCCC”, “Chennai”);        User user4 = new User(4,”DDD”, “Kochin”);        User user5 = new User(5,”AAAA”, “US”);        Collection<User> users =new ArrayList<User>();        users.add(user1);        users.add(user2);        users.add(user3);        users.add(user4);        users.add(user5);        Collection<String> userNames = CollectionUtil.getPropertyValuesAsCollection(users, “name”, String.class, false);        for (String userName : userNames)        {            System.out.println(userName);        }                Collection<Integer> ids = CollectionUtil.getPropertyValuesAsCollection(users, “id”, Integer.class, false);        for (Integer id

Continue reading »

Multiple DataSource configurations using Spring

While developing Java based applications we might frequently need to change the database properties based on the environment we are working like PRODUCTION, DEVELOPMENT OR UAT environments. In that situations the following approach will be useful and easy to configure database properties for each environment. If we want to change the environment we just need to change the ENV property value. <bean id=”placeholderConfigurer” class=”org.springframework.beans.factory.config.PropertyPlaceholderConfigurer”>      <property name=”ignoreResourceNotFound” value=”true”></property>      <property name=”ignoreUnresolvablePlaceholders” value=”true”></property>      <property name=”nullValue” value=”NULL”></property>      <property name=”locations”><list><value>jdbc.properties</value></list></property></bean> <bean id=”dataSource” class=”com.spring.dao.JDBCConfig”><property name=”driverClassName” value=”${${Env}.jdbc.driverClassName}”></property><property name=”url” value=”${${Env}.jdbc.url}”></property><property name=”username” value=”${${Env}.jdbc.username1}”></property><property name=”password” value=”${${Env}.jdbc.password}”></property> </bean> jdbc.properties*****************************Env=PROD jdbc.driverClassName=${${Env}.jdbc.driverClassName}jdbc.url=${${Env}.jdbc.url}jdbc.username=${${Env}.jdbc.username}jdbc.password=${${Env}.jdbc.password} ######### JDBC Configuration for DEV Environment ###############DEV.jdbc.driverClassName=com.mysql.jdbc.DriverDEV.jdbc.url=jdbc:mysql://localhost:3306/devportalDEV.jdbc.username=DEVuserDEV.jdbc.password=DEVpwd ######### JDBC Configuration for UAT Environment ############UAT.jdbc.driverClassName=com.mysql.jdbc.DriverUAT.jdbc.url=jdbc:mysql://localhost:3306/UATportalUAT.jdbc.username=UATuserUAT.jdbc.password=UATpwd ##########

Continue reading »

Java Versions and Code Names

VERSION CODE NAME RELEASE DATE JDK 1.1.4 Sparkler Sept 12, 1997 JDK 1.1.5 Pumpkin Dec 3, 1997 JDK 1.1.6 Abigail April 24, 1998 JDK 1.1.7 Brutus Sept 28, 1998 JDK 1.1.8 Chelsea April 8, 1999 J2SE 1.2 Playground Dec 4, 1998 J2SE 1.2.1 (none) March 30, 1999 J2SE 1.2.2 Cricket July 8, 1999 J2SE 1.3 Kestrel May 8, 2000 J2SE 1.3.1 Ladybird May 17, 2001 J2SE 1.4.0 Merlin Feb 13, 2002 J2SE 1.4.1 Hopper Sept 16, 2002 J2SE 1.4.2 Mantis June 26, 2003 J2SE 5.0 (1.5.0) Tiger Sept 29, 2004

Continue reading »

JDBC DataSource Configuration in Tomcat

Put a file named context.xml in META-INF folder which contains: <?xml version=”1.0″ encoding=”UTF-8″?> <Context><Resource name=”MySQLDS” type=”javax.sql.DataSource” driverClassName=”com.mysql.jdbc.Driver” password=”root” maxIdle=”2″ maxWait=”5000″ username=”root” url=”jdbc:mysql://localhost:3306/test” maxActive=”10″/></Context> Getting the DataSource: Context context = new InitialContext();DataSource MYSQL_DATASOURCE = (DataSource) context.lookup(“java:comp/env/MySQLDS”);

Continue reading »

How to kill a process running on a port

Hi All,Many of the Java developers frequently facing some problems with ports.Ex: If JBoss server has started and closed accedentally without properly shutdown process , several processes will remain running on some ports which will causes Port Already binded kind of exceptions.In that kind of situations, we can forcefully kill a process running on a port as follows:1. get the PID of that processd:>netstat –ao 2. kill the processD:>taskkill /F /PID p_id

Continue reading »

Struts1 Vs Struts2 Vs JSF Vs SpringMVC

Hi, Recently I have done some research on J2EE Web frameworks usability and features to decide the framework to be used for one of my new projects.I consider Struts 1, Struts2, JSF and Spring MVC. After spending some hours on going through each of the frameworks features and some more hours to do a simple application(Proof Of Concept).In this process i was excited looking at some of the features, become a fan of one of the frameworks, felt home sick to leave my all time favourite framework and irritated with some of the frameworks. Struts1: This is my all time

Continue reading »

What is Inversion Of Control (IOC)?

Inversion Of Control is a design pattern which suggests the creation of collaborating objects and injecting them should not be done by the dependent object itself. For example, Suppose WhetherController(Servlet) is depend on WhetherService which is depend WhetherDAO. WhetherController .javaclass WhetherController extends HttpServlet{ protected doPost(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { WhetherService service = new WhetherService(); service.doSomething(params);….…. }} WhetherService.javaclass WhetherService{ public void doSomething(Map params) { WhetherDAO dao = new WhetherDAO();dao.getWhetherReport(); }} WhetherDAO.javaclass WhetherDAO{ // code to interact with Database} If you code as said above and if it is a big project you may use WhetherService/WhetherDAO in several classes.

Continue reading »

Welcome note

Hi All,Welcome guys. This is a blog where in you can find tutorials on various Java and J2EE technologies and can have discussions regarding technical problems and application development related issues.

Continue reading »