Sunday, 6 October 2013

Money Transfer within India without Bank Account (India Post Online Money Order)

Money Transfer within India

Few days ago i was trying to find a way to transfer money to some one within India who has no bank account. If both sides have bank account then its not a problem (there are many ways like net-banking, NEFT in Banks, sending cheques). But if the receiver don't have any bank account then it becomes a problem. Especially when the sender is also from India. If you are outside India then you can use Western Union Money Transfer, but it does not work if both sender and receiver are within India. In such cases we remember the old service of "Money Order". This service seems to belong to age of our grandparents but its still working and developed itself according to the modern technologies.

There are two types of Money Order facilities available now:

  • Electronic Money Order (EMO)
  • Instant Money Order (IMO)

Electronic Money Order (EMO)

Electronic Money Order (EMO) is a good way to transfer money if the sender have a bank account and the reciever don't have a bank account. You can visit www.epostoffice.gov.in , official website of Indian Postal Department. This website provides a virtual post office. Now go to the Electronic Money Order counter. It will ask you to register if you are using it for first time, else you can use your username and password to enter into it. From this page you can can money to anybody in india who does not have a bank account. You can make payment through Internet Banking. At Present it supports only Axis Bank Internet Banking. But it may include support for more banks very soon. Its possible that it has already done this while you are reading this article.
Electronic Money Order (EMO) Tariff Charges
  • EMO commision of Rs 5 on every Rs 100.
  • 2.0256 % eMO payment Gateway Charges.
  • So Totally it will be 7.02% of total amount.
Its comparably costly than any other mode of transfer. 

Instant Money Order (IMO)

Instant Money Order (IMO) provides the facility to transfer money within 1 minute. Using it you can transfer any amount ranging between Rs 1000 to Rs 50000 . You have to visit IMO counter in your nearest Post Office. There you will have to fill a form and submit it with the Amount and Commission. In return you will get a 16 digit code. You can send it to the person, to whom you are sending the money, at your own risk. That person can visit nearest IMO Counter with a valid ID proof and 16 digit Code. Using it he/she can collect the amount. Instant Money Order is just like Domestic version of Western Union Money Transfer. Isn't it good !

Instant Money Order (IMO) Tariff Charges


  • Rs 1000 to Rs 10000 : Rs 100
  • Rs 10001 to Rs 30000 : Rs 110
  • Rs 30001 to Rs 50000 : Rs 120


Saturday, 5 October 2013

creating a simple struts application

Struts is a java framework used to implement the MVC  architecture more effectively.  In this post i explain some simple steps to create a java web application using the struts framework. For this demonstration i use the Netbeans IDE.

Here i am going to create a simple login validation web application. In the login page there are two fields, first one is the name field and second one is an email field. If user enter any improper contents for any of these fields then  display an error message on the same login page using struts framework. You have to follow the steps given bellow for creating this simple strut application by yourself.

Step 1:
Create a java web application with name "StrutDemo" and choose the Struts framework from the frameworks window on the netbeans ide and click finish.
Now the IDE creates the project and a welcomeStruts.jsp page will appear on the editor window of the ide. The project hierarchy  is shown bellow.
Step 2:
Create the login.jsp page. (Right click the project choose new option and select jsp. ) Name the jsp page as "login.jsp". At the top of the login.jsp page add the following tag libraries. 
 <%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>  
<%@taglib uri="http://struts.apache.org/tags-html" prefix="html" %>

Now create the following html form in the body tag of  login.jsp page. Make sure that the action of the html form is "/login".
  <html:form action="/login">  
<table>
<tr>
<td>Enter Name :</td>
<td><html:text name="LoginForm" property="name" /></td>
</tr>
<tr>
<td>Enter Email :</td>
<td><html:text name="LoginForm" property="email" /></td>
</tr>
<tr>
<html:submit value="Login" />
</tr>
</table>
</html:form>

Notice that the value provided for the name attribute in the html text tag is the name of the Struts ActionForm Bean that we are going to create in this application. Property is the name of the variables in the ActionForm Bean class.

Step 3:
Create the Struts ActionForm Bean.  Right click the project, choose new and select other. Form the categories select Struts. From Struts choose the Struts ActionFrom Bean and click next.

Provide LoginForm for class name and choose the package and click finish.

By default the IDE creates two variables on the Bean class name and number. Also there is setter and getter methods for name and number. We have to add two additional String variables email and error. The email variable is for getting the value of email from the html form and the error variable is for setting the error message when user enter wrong data on the input form in the login.jsp. Now you need to add getter and setter for email and error variables. For adding this methods just place your cursor on the variable name and press alt + insert on the keyboard and choose getter and setter. We do't need the number variable. So you may have to delete it. After doing all these above steps the LoginForm.java look like this.

LoginForm.java
 package com.myapp.struts;  
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
/**
*
* @author prabeesh
*/
public class LoginForm extends org.apache.struts.action.ActionForm {
private String name;
private String email;
private String error;
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getError() {
return error;
}
public void setError() {
this.error = "<span style='color:red'>Please enter valid data for both fields</span>";
}
public String getName() {
return name;
}
public void setName(String string) {
name = string;
}
public LoginForm() {
super();
// TODO Auto-generated constructor stub
}
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
if (getName() == null || getName().length() < 1) {
errors.add("name", new ActionMessage("error.name.required"));
// TODO: add 'error.name.required' key to your resources
}
return errors;
}
}

Note that we set the error message on the setError() method.
 public void setError()  
{
this.error = "<span style='color:red'>Please enter valid data for both fields</span>";
}

Step 4:
 Make the success.jsp . Right click the project choose new option and  select jsp. Name the file as success. On the same window choose  folder by click browse and select WEB-INF folder and click finish.

Now edit the success.jsp file as shown bellow.
 <%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>  
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Login Success</h1>
<p>Your Name :<bean:write name="LoginForm" property="name" /></p>
<p>Your Email :<bean:write name="LoginForm" property="email" /></p>
</body>
</html>

Don't forget to add the bean tag library at the top of success.jsp.  We print the values for name and email by using the <bean:wrie /> tag.

Step 5:
Create Struts Action class. Right click the project choose new select other and select Struts in the categories and choose Struts Action and click next.

Provide LoginAction for class name, choose the package and type /login for action path and click next.

Remove the forward slash from the Input Resource field and dis select the validate ActionForm Bean and click finish.

We are going to done the validation on the execute() method of the Action class as shown bellow.

LoginAction.java
 public class LoginAction extends org.apache.struts.action.Action {  
private static final String SUCCESS = "success";
private static final String FAILURE = "failure";
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
LoginForm loginBean = (LoginForm)form;
String name,email;
name = loginBean.getName();
email = loginBean.getEmail();
if(name==null || email==null || name.equals("")||email.indexOf("@")==-1)
{
loginBean.setError();
return mapping.findForward(FAILURE);
}
return mapping.findForward(SUCCESS);
}
}

Step 6:
Add the error message on the login.jsp page using the <bean:write /> tag. Complete source of login.jsp is given bellow.

login.jsp
 <%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>  
<%@taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<html:form action="/login">
<table>
<tr>
<td><bean:write name="LoginForm" property="error" filter="false" /></td>
</tr>
<tr>
<td>Enter Name :</td>
<td><html:text name="LoginForm" property="name" /></td>
</tr>
<tr>
<td>Enter Email :</td>
<td><html:text name="LoginForm" property="email" /></td>
</tr>
<tr>
<html:submit value="Login" />
</tr>
</table>
</html:form>
</body>
</html>

Step 7:
Open struts-config.xml right click anywhere in it from strut choose the add forward option.

Type success as Forward name, choose success.jsp in the WEB-INF folder as Resource file by clicking the browse button. Provide /login as action and click add button.

In the same way you need to add Action Forward for failure also. After adding action Forwards for both success and failure  you can see the following forward tags on the strut-config.xml file.
 <action-mappings>  
<action name="LoginForm" path="/login" scope="session" type="com.myapp.struts.LoginAction" validate="false">
<forward name="success" path="/WEB-INF/success.jsp"/>
<forward name="failure" path="/login.jsp"/>
</action>
<action path="/Welcome" forward="/welcomeStruts.jsp"/>
</action-mappings>

Step 8 :
Open the web.xml file under the WEB-INF folder. Select pages and type login.jsp for welcome files.

Step 9:
Save the project and run. You go the following outputs.


Thursday, 3 October 2013

Imagemap creation for SEO purposes

It's not a kind of doing, what you can use on each corner. But such hint could help you to diversify and enrich your assets and to gain the spreading of your source. But don't misuse - you could be just quickly abused;) Google doesn't like if you become oversmart. I'm talking about imagemaps, the links inside of imagemaps and making use of imagemaps for SEO purposes.
Read full article »

Wednesday, 2 October 2013

pass by reference in java

In java there is no pointer concepts. So pass by reference using pointer is not possible in java. In java pass by reference is achieved by passing objects as arguments. It is possible to pass objects as argument to a function in java. In this post i am going to explain how to pass an object as reference in java.
Ads by Google


For better understanding consider the code segment given bellow. 
      class TestClass  
{
String msg;
public TestClass(String msg)
{
this.msg = msg;
}
public boolean checkObject(TestClass obj)
{
if(obj.msg.equals(msg))
return true;
else
return false;
}
}
public class ObjectPassing
{
public static void main(String args[])
{
TestClass test1 = new TestClass("Apple");
TestClass test2 = new TestClass("Orange");
TestClass test3 = new TestClass("Apple");
System.out.println("test1 = test2 :"+test1.checkObject(test2));
System.out.println("test1 = test3 :"+test1.checkObject(test3));
}
}

In this example the TestClass contain a method called checkObject, which accept an object as argument. Here you can see that the type of the argument is the name of the class.
     public boolean checkObject(TestClass obj)  
{
if(obj.msg.equals(msg))
return true;
else
return false;
}

Here we check the value of the variable "msg" for the three objects test1, test2 and test3. In this method if the value of the variable "msg" corresponding  to the two objects is found to be true, then it return true otherwise false.
Here is the output of the program.



Constructor Overloading                                        Index                 

Tuesday, 1 October 2013

constructor overloading in java

Like method overloading you can also overload a constructor in java. A constructor is a special purpose class member function for initializing the objects of a class.  A constructor is overloaded on the basis of the arguments or parameters available with it.
Ads by Google


Consider the following class.
     class ConstructorTest  
{
int a,b;
public ConstructorTest()
{
a = 10;
b = 20;
System.out.println("From the default constructor a = "+a+ " and b ="+b);
}
public ConstructorTest(int a,int b)
{
this.a = a;
this.b = b;
System.out.println("From the parameterised constructor a = "+a+ " and b ="+b);
}
}


In this class you can see that there is two constructors present. One is with no arguments and other is with two integer parameters. The compiler will invoke the appropriate constructor when a compatible object initialization found.

For example the statement "ConstructorTest t1 = new ConstructorTest();" will invokes the default constructor, while the statement" ConstructorTest t2 = new ConstructorTest(30,40);" will invoke a constructor with two integer parameters.

Method overloading                                           Index                                Pass by reference