public String registration() throws IOException {
		System.out.println("email in reg="+email);
		System.out.println("pw in reg="+password);
		System.out.println("cpw in reg="+confirmpassword);
		
		 String resource = "orm/configuration.xml";
			Reader reader = Resources.getResourceAsReader(resource);
			SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(reader);
			SqlSession session = sessionFactory.openSession();
      
			try{     
               
      		String check = "\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*";
			Pattern regex = Pattern.compile(check);
			java.util.regex.Matcher matcher = regex.matcher(email);
			boolean isMatched = matcher.matches();
			
            userlist = session.selectList("selectuserbyemail", email);
	
                 
/*check whether the email address is valid */
                 	
      if(email.equals("")||password.equals("")||confirmpassword.equals(""))
     {
        
        JOptionPane.showMessageDialog(null,"Please fill required information!","Message",JOptionPane.WARNING_MESSAGE);
     }
     else if(!confirmpassword.equals(password))
     {
     JOptionPane.showMessageDialog(null,"Two passwords don't match, please type again!","Message",JOptionPane.WARNING_MESSAGE);
     }
     else if(!isMatched)
     {
    	 JOptionPane.showMessageDialog(null,"This email address is invalid!","Message",JOptionPane.WARNING_MESSAGE);
     }
     
     else if(!(userlist.isEmpty()))
     {
    	 JOptionPane.showMessageDialog(null,"This email address has been registered!","Message",JOptionPane.WARNING_MESSAGE);
			      }
      
         
     else {
    	 //insert new user
    	 newuser=new user();
    	 newuser.setEmail(email);
    	 newuser.setPwd(password);
         session.insert("insertuserinfo",newuser);
 	    session.commit();	
        JOptionPane.showMessageDialog(null,"Registered Successfully!","Message",JOptionPane.INFORMATION_MESSAGE);
            return SUCCESS;
     }

             }finally{
                 session.close();
             }
             
             return "fail";
	}