Tuesday, June 25, 2013

Upcoming super star of film industry :- Tovino Thomas

Tovino Thomas called as "Tovi" is one of the most promising and talented super star in the Malayalam film industry.Tovino started his filmy career with the movie "Prabhuvinte Makkal ". He had played an villain role in the latest super hit Malayalam movie "ABCD".Tovino's upcoming movie includes "YOU TOO BRUTUS" directed by famous director "Roopesh Peethambaran".Tovino has worked as a model and even lend his face for few short films and advertisements. Maathra, Jaalakam and Snehapoorvam were the short films which proved him as an actor.

For all those who have missed this dude's pics here are few............

































Saturday, May 25, 2013

Naresh Iyer's new musical album :- Vennila

Naresh Iyer is back with a super hit musical album  Vennila .

Please click on the below image to listen/download vennila

Inline image 2



Vennila available @
1) vennilamusic.com/song/Vennila.mp3
2) http://www.4shared.com/zip/VazstO6o/Vennila.html
3) http://subinsuresh.blogspot.in/2013/05/naresh-iyers-new-musical-album-vennila.html
4) https://soundcloud.com/ajith1989/vennila 

Get day difference between two dates

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
   /**
         * @param date1
         * @param date2
         * @return
         */
        public static long getDayDifference(Date date1, Date date2) {

                long diffDays = 0;
                if(null != date1 && null != date2){
                        Calendar c1 = Calendar.getInstance();
                        c1.setTime(date1);

                        Calendar c2 = Calendar.getInstance();
                        c2.setTime(date2);
                        double milliseconds1 = c1.getTimeInMillis();
                        double milliseconds2 = c2.getTimeInMillis();
                        double diff = milliseconds2 - milliseconds1;
                        diffDays = (long) diff / (24 * 60 * 60 * 1000);
                      
                }
                return diffDays;
        }

Saturday, May 14, 2011

Subtract ndays from given Date

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
 
   /**
         * @param date
         * @param days
         * @param format
         * @return
         */
        public static String subtractDays(Date date, Integer days,String format) {

              
                String formattedDate = null;
                if(null != date && null != format){
                        Calendar calendar = Calendar.getInstance();
                        calendar.setTime(date);
                        calendar.add(Calendar.DATE, -days);
                        SimpleDateFormat dateFormat = new SimpleDateFormat(format);
                        formattedDate=dateFormat.format(calendar.getTime());
                }
                return formattedDate;
        }

Monday, May 9, 2011

Adding ndays to given Date

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

       /**
         * @param date
         * @param days
         * @param format
         * @return

         */
        public static String addDays(Date date, Integer days, String format) {

                String formattedDate = null;
                if(null != date && null != format){
                        Calendar calendar = Calendar.getInstance();
                        calendar.setTime(date);
                        calendar.add(Calendar.DATE, days);

                        SimpleDateFormat dateFormat = new SimpleDateFormat(format);
                        formattedDate = dateFormat.format(calendar.getTime());
                }
              
                return formattedDate;
        }
      


Saturday, February 26, 2011

What is a Framework?

Framework is special software that is capable of developing applications based on certain architecture having ability to generate certain logics of application development dynamically.

Sunday, December 5, 2010

Implementation of Connection Pooling for PostgreSQL in Tomcat6.0


  1. Copy the below Resource tag in between open tag <Context> and end tag          </Context> of context.xml available in META-INF directory of your Web Application
For Example
D:\SampleWeb\web\META-INF

<Context>
                                                                                                                         
<Resource name="jdbc/psql"
    auth="Container"
    type="javax.sql.DataSource"
    maxActive="100"
    maxIdle="30"
    maxWait="20000"
    removeAbandoned="true"
    removeAbandonedTimeout="120"
    username="postgres"
    password="postgres"
    driverClassName="org.postgresql.Driver"
    url="jdbc:postgresql://127.0.0.1:5432/testdb"/>

</Context>


2. Copy the same above Resource tag in between open tag <Context> and end tag        </Context> of context.xml available in Tomcat’s conf directory.

For example
           C:\Program Files\Apache Software Foundation\Tomcat 6.0\conf\
<Context>

<Resource name=" jdbc/psql"
    auth="Container"
    type="javax.sql.DataSource"
    maxActive="100"
    maxIdle="30"
    maxWait="20000"
    removeAbandoned="true"
    removeAbandonedTimeout="120"
    username="postgres"
    password="postgres"
    driverClassName="org.postgresql.Driver"
    url="jdbc:postgresql://10.1.14.38:5432/testnpermit"/>

</Context>

3. You can have any number of Resource tags as you wish but names must be different.
    

4. Copy the postgresql-8.4-701.jdbc3.jar in Tomcat’s lib directory
  C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib
 
 
 
5. Create a Java Class ConnectionPooling
 

import java.sql.Connection;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
import nic.java.util.Debug;

public class ConnectionPooling {

    private static DataSource ds;

    public static Connection getDBConnection() throws NamingException, Exception {

        Connection con = null;
        try {
            if (ds != null) {
                con = ds.getConnection();
            } else {
                String dsString = "java:/comp/env/ jdbc/psql";
              ds = (DataSource) new InitialContext().lookup(dsString);
                con = ds.getConnection();
            }

        } catch (Exception e) {
            e.printStackTrace();
                  }
        return con;
    }
}

Sunday, November 28, 2010

Postgres Query to find difference between months

select ( date '2010-01-01', interval '4 months') overlaps 
 ( date '2010-04-30', date '2010-04-30') as flag
This Query  returns true if difference between months is 4 or less than 4 months 
in postgresql and returns false if difference is morethan 4 months

Tuesday, November 2, 2010

Remove Duplicate value from ArrayList

ArrayList arrayListSubin = new ArrayList();
  
 
arrayListSubin.add("A");
 
arrayListSubin.add("A");
 
arrayListSubin.add("B");
 
arrayListSubin.add("B");
 
arrayListSubin.add("B");
 
arrayListSubin.add("C");
  
  //Create a HashSet which allows no duplicates
  HashSet hashSet = new HashSet(
arrayListSubin);

  //Assign the HashSet to a new ArrayList
  ArrayList arrayList2 = new ArrayList(hashSet) ;
  
  //Ensure correct order, since HashSet doesn't
  Collections.sort(arrayList2);
  
  for (Object item : arrayList2)
    System.out.println(item);

Note that you will have to sort the ArrayList if you want to be sure that the items remain
in correct order by calling the sort method of the Collection class.

This will produce the following output:

A
B
C

Monday, November 1, 2010

Connection Pooling in Tomcat6.0

Connection Pooling: is a pool of pre-established connections. Connection Pooling is the art of an Application. A connection with the database is a heavy weight process and if it is not created properly it downs the performance of the Application.

Connection Pooling can be maintained either in Applications level or in Web or Application Server level. Struts and Hibernate frame works are providing Application level Connection Pooling

Connection Pooling is provided by Web Server and Applications Server vendors. Implementation of Connection Pooling is different from Server to Server.

Implementation of Connection Pooling for Oracle 8i, 9i & 10g in Tomcat6.0


1. Copy the below Resource tag in between open tag <Context> and end tag </Context> of context.xml available in Tomcat’s conf directory.
For example
   C:\Program Files\Apache Software Foundation\Tomcat 6.0\conf\
<Context>
           <Resource name="jdbc/myoracle" auth="Container"
              type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver"
              url="jdbc:oracle:thin:@127.0.0.1:1521:mysid"
              username="scott" password="tiger" maxActive="20" maxIdle="10"
              maxWait="-1"/>          
</Context>

2. You can have any number of Resource tags as you wish but names must be different.

3. Copy the below tag in web.xml in WEB-INF available in your Web Project
<web-app>
    <resource-ref>
    <description>Oracle Datasource example</description>
    <res-ref-name>jdbc/myoracle</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>
    </web-app>
 
  Copy the ojdbc14.jar in Tomcat’s lib directory say
  C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib
  
4. Create a Java Class ConnectionPooling
 
import java.sql.Connection;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;

public class ConnectionPooling {
    private static DataSource ds;
public static Connection getDBConnection() throws NamingException {
Connection con =null;
    try {
  
if( ds!=null)
{
con =ds.getConnection();
}else
{
 Context initContext = new InitialContext();
    Context envContext = (Context)       initContext.lookup("java:/comp/env");
    DataSource ds = (DataSource) envContext.lookup("jdbc/myoracle");
    con = ds.getConnection();
}   
} catch (Exception e) {
    e.printStackTrace();
    }
    return con;
    }
}


Now Connection pooling has been setup now  test your application using this connection pooling.

Thursday, October 28, 2010

Java program to reverse contents in a file

Below contains java program to read the contents of a file,reverse the contents of the file and write it back to the file.

1)create text.txt in D: drive of your system and type the contents say subin suresh
2)Create java class and type the below code
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package reverse;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;

/**
*
* @author subin_s
*/
public class Main {

/**
* @param args the command line arguments
*/
public static void main(String[] args) throws FileNotFoundException, IOException {
Scanner scanner = new Scanner(new File("D:/test.txt")).useDelimiter("\\Z");
String contents = scanner.next();
System.out.println("Original String : " + contents);
contents = new StringBuffer(contents).reverse().toString();
System.out.println("Reversed String : " + contents);
FileWriter fstream = new FileWriter("D:/test.txt");
BufferedWriter out = new BufferedWriter(fstream);
out.write(contents);
out.close();
}
}

3)Output
Original String : subin suresh
Reversed String : hserus nibus

Thursday, October 21, 2010

Problems if <h:form> is not used in JSF

I will be explainingpProblems if <h:form> is not used in JSF with a simple example.
1)I created a new project in JSF and added comman button to the jsp page  without using <h:form&gt tag
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<%--
    This file is an entry point for JavaServer Faces application.
--%>
<f:view>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
            <title>JSP Page</title>
        </head>
        <body>
            <h1><h:outputText value="JavaServer Faces"/></h1>
                <h:commandButton id="bt_SAVE"  value="Save" action="#{test.saveProcess}" />
        </body>
    </html>
</f:view>

2) Made necessary mapping in faces-config.xml.
<managed-bean>
        <managed-bean-name>test</managed-bean-name>
        <managed-bean-class>bean.test</managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
    </managed-bean> 


3) Created package bean and added test class to the bean package
 /*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bean;

/**
 *
 * @author subin_s
 */
public class test {

    public void saveProcess() {
        System.out.println("Debug inside saveProcess");
    }
}



Now if you run the project and click on save button  saveProcess method will not be executed you may think why button is not working ,problem is  you have not given <h:form> tag.

Tuesday, October 19, 2010

Adding Struts 2 plugin to NetBeans 6.8

Today we will see Struts 2 plugin for NetBeans 6.8 .First you need to download 2 files
org-netbeans-modules-web-frameworks-struts2.nbm
org-netbeans-modules-web-frameworks-struts2lib20011.nbm

 
Installing Module
1) Tools --> plugins --> --> Downloaded
  Click on AddPlugins

2)Select files from your system

3) Click open

4) Install
5) Follow the wizard one validation warning may come  then click continue button and then restart netbeans.
Now you can start developing Struts 2 Application in netbeans.

Monday, October 18, 2010

Submitting project into cvs in linux

Today we will see one of  important topic regarding CVS(Concurrent Versions System).  
How to Submit project into cvs in linux.
open the terminal
enter into the root
navigate to the project folder say /home/subin/Desktop/Projectname(Come inside project folder)
type below command
cvs import -m "new Projectname" -I ! -W "*.doc -kb" -W "*.gif -kb" -W "*.JPEG -kb" -W "*.jar -kb" -W "*.BMP -kb" -W "*.jpg -kb" -W "*.PNG -kb" Projectname nic v20

cvs commit;
Now project has been submitted to CVS successfully
To check out project from cvs type below command

cvs checkout Projectname

chmod -R 777 Projectname  --- this command will give permissions to access all sub folders and files (read, write, modify)

Friday, October 15, 2010

Multiple sign in feature of Google

Google recently rolled out with multiple sign in feature. It means you can login to multiple Google (including Gmail) accounts in the same browser.
To start with the service, go to Google.com and login with your Google credentials. Now click on Settings –> Google account settings.

On account settings page, under Multiple sign-in section, click on the “Edit” link.


A new page will appear along with the notification in yellow color. This facility is currently available on Gmail, Google Calendar, Google Sites, Google Reader and Google Code.
Click on the On option and check all the boxes under it (obviously read them carefully before checking). After checking, click on the “Save changes” button.

Now login to my Gmail account. On the top right, a drop-down appears next to my email address as shown below .
Click on the drop down and then click on “Sign in to another account”. A new tab will open, sign in with another Gmail account.


Thursday, October 14, 2010

Google’s new website “Google New”

Google’s new website named as “Google New” was launched by Google few days back. It represents all the latest updates in various sections of Google products through their blogs.
Google New is a service launched to help a Google fan to stay updated with all the updates and development happening in various Google products, all at one place.

Link for Google New
Below shows screenshot of  home page of  “Google New”.

Find Technology Being Used by Other Site using Sitonomy

Sitonomy service shows following details:
Blogging platform, Widgets being used by the site, advertising network, Server software, Subscription method, Analytic method and few more details.
 Link for Sitonomy

Here is a screenshot of  Subin'sWorld Sitonomy:

Tuesday, October 12, 2010

Making RichCalender Editable

Few days back we i have posted  Server Side Date Validator Today we will discuss  topic how to manually enter date in  rich calender only you need to do is set enale ManualInput to true  in jsp file as shown below.
<rich:calendar id="dc_FROM_DATE" ajaxSingle="true" enableManualInput="true" binding="#{checkUserRequest.dc_FROM_DATE}" inputStyle="font-size:10pt;width:100px;height:25px" datePattern="dd-MM-yyyy">
</rich:calendar>



Sunday, October 3, 2010

Problems in using Value binding in JSF

Today we will see one of the major problem while using value binding in JSF and solution for it.Suppose if we have two fields subject1 and subject2 .In  focus lost of subject2 if we try to get value of subject1 using get method it will give you null value because values are not updated using valuebinding reason for this is while we use value biding  value will be updated in Update Model Value Phase  and value change listener is called  before Update Model Phase.

How to overcome this problem
        PhaseId phaseId = evt.getPhaseId();
        if (phaseId.equals(PhaseId.ANY_PHASE)) {
            evt.setPhaseId(PhaseId.UPDATE_MODEL_VALUES);
            evt.queue();
            return;
        }

Place the above code at the beginning of the method, So automatically updates all the values of the submitted form.

Sunday, September 26, 2010

Tags in JSF

Basically there are two kinds of  tags in JSF.
JSF Core & HTML Tags
Today we will see different  attributes in JSF HTML and Core Tags

JSF HTML Tags :

  • column                              creates column in a dataTable
  • commandButton                creates button
  • commandLink                   creates link that acts like a pushbutton
  • dataTable                         creates a  table control
  • form                                 creates a form
  • graphicImage                    displays an image
  • inputHidden                      creates hidden field
  • inputSecret                       creates input control for password
  • inputText                          creates  text input control (single line)
  • inputTextarea                    creates  text input control (multiline)
  • message                           displays the most recent message for a component
  • messages                          displays all messages
  • outputFormat                    creates  outputText, but formats compound messages
  • outputLabel                      creates label 
  • outputLink                        creates anchor
  • outputText                        creates single line text output
  • panelGrid                         creates html table with specified number of columns
  • panelGroup                      used to group other components where the specification requires one child element
  • selectBooleanCheckbox   creates checkbox
  • selectManyCheckbox       creates set of checkboxes
  • selectManyListbox           creates multiselect listbox
  • selectManyMenu              creates multiselect menu
  • selectOneListbox              creates single select listbox
  • selectOneMenu                creates single select menu
  • selectOneRadio                creates set of radio buttons 

JSF CORE Tags: 

  • f :view                                 Creates the top-level view
  • f:subview                             Creates a subview of a view
  • f:attribute           Adds an attribute  to a component
  • f:param                                Constructs a parameter component
  • f:converter            Adds an arbitrary converter to a component
  • f:converterDateTime      Adds a datetime converter to a component
  • f:converterNumber      Adds a number converter to a component
  • f:actionListener          Adds an action listener to a component
  • f:valueChangeListener     Adds a valuechange listener to a component
  • f:validator             Adds a validator to a component
  • f:validateDoubleRange    Validates a double range for a component’s value
  • f:validateLength         Validates the length of a component’s value
  • f:validateLongRange      Validates a long range for a component’s value
  • f:facet                 Adds a facet to a component
  • f:loadBundle            Loads a resource bundle, stores properties as a Map
  • f:selectitems            Specifies items for a select one or select many component
  • f:selectitem             Specifies an item for a select one or select many component 
  • f:verbatim              Adds markup to a JSF page