Wednesday, June 1, 2011

Spring RowMapper Example, Use of RowMapper, RowMapper Tutorial, jdbcTemplate Example with RowMapper

Interface RowMapper:

org.springframework.jdbc.core.RowMapper
An interface used by JdbcTemplate for mapping rows of a ResultSet on a per-row basis. Implementations of this interface perform the actual work of mapping each row to a result object. One very useful thing is that you can collect all the column of one recrod into java collection.

public class Student {
  private Map data = new HashMap();
  int roll;
}


Means, all the data will be there in map and only one primary column be there outside.

Example here:

Student.java

package binod.suman.rowmapper.domain;
import java.util.HashMap;
import java.util.Map;
public class Student {
 private Map data = new HashMap();

 int roll;

 public void putObject(String key, Object value) {
  data.put(key, value);
 }

 public Object getObject(String key) {
  return data.get(key);
 }

 public Student(int roll) {
  super();
  this.roll = roll;
 }

 public int getRoll() {
  return roll;
 }
 public void setRoll(int roll) {
  this.roll = roll;
 }
 @Override
 public String toString() {
  return "Name : "+data.get("sname")+" \nCity : "+data.get("city")+" \nRoll Number : "+roll;
 }


}

StudentResultSetReader.java

package binod.suman.rowmapper.dao;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import org.springframework.jdbc.core.RowMapper;
import binod.suman.rowmapper.domain.Student;
public class StudentResultSetReader implements RowMapper {
 public StudentResultSetReader() {
 }

 public Student read(ResultSet rs) throws SQLException {
  Student t = new Student(rs.getInt("roll"));
  ResultSetMetaData md = rs.getMetaData();
  int numCols  = rs.getMetaData().getColumnCount();
  for (int i = 1; i <= numCols; i++) {
   t.putObject(md.getColumnName(i), rs.getObject(i));
  }
  return t;
 }
 @Override
 public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
  return read(rs);
 }
}

StudentDAO.java

package binod.suman.rowmapper.dao;

import java.util.List;
import binod.suman.rowmapper.domain.Student;
public interface StudentDAO {
// public void insertStudent(Student s);
 public Student selectStudent(int roll);
 public List selectAllStudent();
}


beanx.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://www.springframework.org/schema/beans"
 http://www.springframework.org/schema/beans/spring-beans.xsd"/ >

 <bean id="dataSource" destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource">
        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
        <property name="url" value="jdbc:mysql://localhost/suman"/>
        <property name="username" value="root"/>
        <property name="password" value="mysql"/>
    </bean>
 
 <bean id="studentDAO" class="binod.suman.rowmapper.dao.StudentDAOImpl">
  <property name="dataSource" ref="dataSource"/>
 </bean>

</beans>
Main.java

package binod.suman.rowmapper.dao;
import java.util.List;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import binod.suman.rowmapper.domain.Student;

public class Main {
 public static void main(String[] args) {
  ApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");
  StudentDAO studentDAO = (StudentDAO) context.getBean("studentDAO");
//  Student student = new Student(251,"Binod Suman", "Espoo");
//  studentDAO.insertStudent(student);
  Student ss = (Student)studentDAO.selectStudent(150);
  System.out.println(ss);
 
  List ssList = studentDAO.selectAllStudent();
  System.out.println("Total Record :: "+ssList.size());
  for(Student s : ssList){
   System.out.println("******************");
   System.out.println(s);
   }
  }
}


Jar files required:
org.springframework.asm-3.0.0.M3.jar
org.springframework.beans-3.0.0.M3.jar
org.springframework.context-3.0.0.M3.jar
org.springframework.context.support-3.0.0.M3.jar
org.springframework.core-3.0.0.M3.jar
org.springframework.expression-3.0.0.M3.jar
org.springframework.jdbc-3.0.0.M3.jar
org.springframework.transaction-3.0.0.M3.jar
mysql-connector-java-3.1.12-bin.jar
antlr-runtime-3.0.jar
commons-dbcp.jar
commons-logging-1.0.4.jar
commons-pool.jar
hsqldb.jar

You need to create one database schema with name suman and one student table shoule be there:

CREATE TABLE student (
  sname varchar(100) default NULL,
  roll int(4) NOT NULL,
  city varchar(100) default NULL,
  PRIMARY KEY  (`roll`)
)

and some data should be there:
insert into student ('Binod',150,'Helsinki');

Details documentation on RowMapper. 

Thanks,

Binod Suman

Tuesday, May 10, 2011

Spring Integration Messaging tutorial, Spring Integration in 10 Minutes


There are many things in Spring Integration:

1. Messaging
2. Routing
3. Mediation
4. Invocation
5. CEP (Complex Event Processing)
6. File Transfer
7. Shared database
8. Remote Procedure call

Here I am posting Spring Integration Messaging (Kind of JMS) example here:

Create one project in Eclipse say SpringIntegrationDemo and add these below jar file to that project:

1. spring-core-3.0.5.RELEASE.jar
2. spring-integration-core-2.0.0.BUILD-SNAPSHOT.jar
3. jar/commons-logging-1.1.jar
4. spring-context-3.0.5.RELEASE.jar
5. spring-beans-3.0.5.RELEASE.jar
6. spring-asm-3.0.5.RELEASE.jar
7. spring-expression-3.0.5.RELEASE.jar
8. spring-aop-3.0.5.RELEASE.jar
9. aopalliance-1.0.jar

In src folder, create these three files:
1. MyService.java
2. myServiceDemo.xml
3. MyServiceDemo.java

MyService.java

public class MyService {

 public String sayHello2(String name) {
  return "Suman Hello :  " + name;
  }

}

myServiceDemo.xml

<?xml version="1.0" encoding="UTF-8"?>
&it;beans:beans xmlns="http://www.springframework.org/schema/integration"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:beans="http://www.springframework.org/schema/beans"
 xsi:schemaLocation="http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans.xsd
   http://www.springframework.org/schema/integration
   http://www.springframework.org/schema/integration/spring-integration.xsd" >

 <channel id="inputChannel"/>
 <channel id="outputChannel">
  <queue capacity="10"/>
 </channel>
 
 <service-activator input-channel="inputChannel"
                    output-channel="outputChannel"
                    ref="myService"
                    method="sayHello2"/>
 <beans:bean id="myService" class="MyService"/>
</beans:beans>

MyServiceDemo.java

import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.message.GenericMessage;
public class MyServiceDemo {

 public static void main(String[] args) {
  AbstractApplicationContext context = new ClassPathXmlApplicationContext("myServiceDemo.xml", MyServiceDemo.class);

  MessageChannel inputChannel =  context.getBean("inputChannel", MessageChannel.class);
  PollableChannel outputChannel =  context.getBean("outputChannel", PollableChannel.class);

// Just senging messages into message channel.
  for(int i=0;i<10;i++){
     inputChannel.send(new GenericMessage<String>("World : "+(i+1)));
  }
 
  // Getting message from message channel
  System.out.println("==> Returning from MyService : " + outputChannel.receive(0).getPayload());
  System.out.println("==> Returning from MyService : " + outputChannel.receive(0).getPayload());
  System.out.println("==> Returning from MyService : " + outputChannel.receive(0).getPayload());
  System.out.println("==> Returning from MyService : " + outputChannel.receive(0).getPayload());
  System.out.println("==> Returning from MyService : " + outputChannel.receive(0).getPayload());
 
 }
}

Now you can run MyServiceDemo file, will get result. :)



 

Saturday, May 7, 2011

How to implement MySql replication Master Master on same Windows machine


How to implement MySql replication Master Master on same windows machine.
In Master Master replication, the change effect to reflect vice varsa. If you change in one master it will effect automatically into other master also and vice varsa.

1. First install mysql-5.5.11-win32.msi on windows machine. While installing choose custom installation and change installation path to D:\MySQL\MySQL Server 5.5
2. Use all the default parameter like Service name is MYSQL and port number is 3306 and setup bin path.
3. And also modify root password to mysql.
3. Now check whether your installation is correct or not.
4.Open dos prompt and type below command.

c:\> mysql -uroot -pmysql -hlocalhost -P3306;
If you get mysql command then everything is ok.
We will treat mysql 5.5 is ACTIVE MASTER.
Now create one database:
mysql> create database suman;

5. Now install another version of mysql (mysql-5.1.56-win32.msi from http://dev.mysql.com/downloads/mysql/5.1.html)  for Passive MASTER. Again while installing choose custome installation and change installation path to D:\MySQL\MySQL Server 5.1

6. Change service name to MYSQL2 and port number to 3307
7. Modify root password to root.
8.Now check whether your installation is correct or not.
9.Open new dos prompot and type below command.

c:\> mysql -uroot -proot -hlocalhost -P3307;
If you get mysql command then everything is ok.
We will treat mysql 5.1 is PASSIVE MASTER.

Up to here two mysql instance are running in your windows machine.
Now start the replication implementation.

1. Open D:\MySQL\MySQL Server 5.5\my.ini then add four options to the [mysqld] section of the my.ini file

[mysqld]
# The TCP/IP Port the MySQL Server will listen on
port=3306
server-id = 1
log_bin = mysql-bin.log
binlog_do_db = suman

save it.
Restart the MYSQL service from your pc. MyComputer -> Right click -> click on Manage -> Services and Application -> Services ->
search MYSQL on right side, right click on that MYSQL and click on restart.

The next step in setting up replication is creating an account that will be used exclusively for replication. We strongly advise creating a dedicated replication user be created for better security so you won't need to grant any additional privileges besides replication permissions. Create an account on the master server that the slave server can use to connect. As mentioned, this account must be given the REPLICATION SLAVE privilege.

Open one dos windows for all MASTER operation.
c:\>mysql -uroot -pmysql -hlocalhost -P3306;
mysql> create user 'user1' identified by 'password';

mysql> grant replication slave on *.* to 'user1'@'%'  identified by 'password';


mysql> flush privileges;
mysql> FLUSH TABLES WITH READ LOCK;
mysql> show master status;
+------------------+----------+--------------+------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000002 |      107 | suman        |                  |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
Please note down this file name and position, it will use to later.


Now some change on PASSIVE MASTER side:
1. Open D:\MySQL\MySQL Server 5.1\my.ini then add four options to the [mysqld] section of the my.ini file

[mysqld]
# The TCP/IP Port the MySQL Server will listen on
port=3307
server-id = 2
log_bin = mysql-bin.log
binlog_do_db = suman

Restart the MYSQL2 service from your pc. MyComputer -> Right click -> click on Manage -> Services and Application -> Services ->
search MYSQL on right side, right click on that MYSQL2 and click on restart.
Open one dos windows for all SLAVE operation.
c:\>mysql -uroot -proot -hlocalhost -P3307;
mysql> stop slave;
mysql> CHANGE MASTER TO
MASTER_HOST='localhost
MASTER_USER='user1',
MASTER_PASSWORD='password',
MASTER_PORT=3306,
MASTER_LOG_FILE='mysql-bin.000002',
MASTER_LOG_POS=107;

Note: Values for the above command taken from Active Master 'show master status' command output.

mysql> show slave status\G;
Output will come huge, among two line should be like:
    Slave_IO_Running: No
    Slave_SQL_Running: No
   
Because slave is stopped now.
Now time came to start slave.
on slave side:
mysql> start slave;
Now check slave status:
mysql> show slave status\G;
Output will come huge, among two line should be like:
    Slave_IO_Running: Yes
    Slave_SQL_Running: Yes
   
 If both values are Yes, then everything are ok.

 Now create user on Passive Master side and give previleges.

mysql> GRANT REPLICATION SLAVE ON *.* TO 'user2'@'%' IDENTIFIED BY 'password';

mysql> show master status;
 +------------------+----------+--------------+------------------+
 | File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
 +------------------+----------+--------------+------------------+
 | mysql-bin.000001 |      106 | suman        |                  |
 +------------------+----------+--------------+------------------+
 1 row in set (0.00 sec)

 Now come again on Active Master side (3306) console and type below command:
  
 mysql> stop slave;

 mysql> CHANGE MASTER TO
 MASTER_HOST='localhost',
 MASTER_USER='user2',
 MASTER_PASSWORD='password',
 MASTER_PORT=3307,
 MASTER_LOG_FILE='mysql-bin.000001',
 MASTER_LOG_POS=106;
Note: Values for the above command taken from Passive Master 'show master status' command output.


mysql> start slave;
mysql> show slave status\G;

 Now you can check your replication work.

 Create some table in MASTER suman database or any database then check at passive MASTER side. Now do some database operation
 at Passive MASTER side and check at Active MASTER side.
Thanks:

Binod Suman

How to implement MySql replication Master Master on same Windows machine

Thursday, May 5, 2011

How to implement MySql replication on same Windows machine.


1. First install mysql-5.5.11-win32.msi on windows machine. While installing choose custom installation and change
installation path to D:\MySQL\MySQL Server 5.5
2. Use all the default parameter like Service name is MYSQL and port number is 3306 and setup bin path.
3. And also modify root password to mysql.
3. Now check whether your installation is correct or not.
4.Open dos prompt and type below command.
c:\> mysql -uroot -pmysql -hlocalhost -P3306;

If you get mysql command then everything is ok.
We will treat mysql 5.5 is MASTER.
Now create one database:

mysql> create database suman;

5. Now install another version of mysql (mysql-5.1.56-win32.msi)  for SLAVE. Again while installing choose custome
installation and change installation path to D:\MySQL\MySQL Server 5.1
6. Change service name to MYSQL2 and port number to 3307
7. Modify root password to root.
8.Now check whether your installation is correct or not.
9.Open new dos prompot and type below command.

c:\> mysql -uroot -proot -hlocalhost -P3307;

If you get mysql command then everything is ok.
We will treat mysql 5.1 is SLAVE.
Now create one database:
mysql> create database suman;

Up to here two mysql instance are running in your windows machine.

Now start the replication implementation.

1. Open D:\MySQL\MySQL Server 5.5\my.ini then add four options to the [mysqld] section of the my.ini file

[mysqld]
log-bin=dellxp1-bin.log
server-id=1
innodb_flush_log_at_trx_commit=1
sync_binlog=1

save it.
Restart the MYSQL service from your pc. MyComputer -> Right click -> click on Manage -> Services and Application -> Services ->
search MYSQL on right side, right click on that MYSQL and click on restart.

The next step in setting up replication is creating an account that will be used exclusively for replication. We strongly advise creating a dedicated replication user be created for better security so you won't need to grant any additional privileges besides replication permissions. Create an account on the master server that the slave server can use to connect. As mentioned, this account must be given the REPLICATION SLAVE privilege.

Open one dos windows for all MASTER operation.
c:\>mysql -uroot -pmysql -hlocalhost -P3306;
mysql> create user 'replication_user' identified by 'password';
mysql> grant replication slave on *.* to 'replication_user'@'%' identified by 'password';
mysql> flush privileges;
mysql> FLUSH TABLES WITH READ LOCK;
mysql> SHOW MASTER STATUS;

+--------------------+----------+--------------+------------------+
| File               | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+--------------------+----------+--------------+------------------+
| dellxp1-bin.000001 |     338 |              |                  |
+--------------------+----------+--------------+------------------+
1 row in set (0.00 sec)

Please note down this file name and position, it will use to later.

Now take your backup of your MASTER database as we have new database so this below step are not required. But when you have to create SLAVE of running database then it step must be required, so lets go these below step too.

Open new dos prompt.

Taking backup from MASTER:
C:\>mysqldump -uroot -pmysql -hlocalhost -P3306 suman > d:\test2.sql

Now export this back to SLAVE, run below command on same dos windows.
C:\Users\sumankbi>mysql -uroot -proot -hlocalhost -P3307 suman < d:\test2.sql

Now some change on SLAVE side:
1. Open D:\MySQL\MySQL Server 5.1\my.ini then add four options to the [mysqld] section of the my.ini file

[mysqld]
server-id=2

save it.
Restart the MYSQL2 service from your pc. MyComputer -> Right click -> click on Manage -> Services and Application -> Services ->
search MYSQL on right side, right click on that MYSQL2 and click on restart.

Open one dos windows for all SLAVE operation.
c:\>mysql -uroot -proot -hlocalhost -P3307;

mysql> stop slave;
mysql> CHANGE MASTER TO
MASTER_HOST='localhost',
MASTER_USER='replication_user',
MASTER_PASSWORD='password',
MASTER_PORT=3306,
MASTER_LOG_FILE='dellxp1-bin.000001',
MASTER_LOG_POS=338;

mysql> show slave status\G;
Output will come huge, among two line should be like:
    Slave_IO_Running: No
    Slave_SQL_Running: No
   
Because slave is stopped now.
Now time came to start slave.
on slave side:

mysql> start slave;
Now check slave status:
mysql> show slave status\G;
Output will come huge, among two line should be like:
    Slave_IO_Running: Yes
    Slave_SQL_Running: Yes
   
 If both values are Yes, then everything are ok.

 Now you can check your replication work.

 Create some table in MASTER suman database or any database (those should be there at SLAVE side) then check at slave side.

 Now you stop slave again then you change of MASTER will not come but once again you will start slave then  slave will get automatically updated from last time stopped pointer.

More details on http://dev.mysql.com/doc/refman/5.0/en/replication.html

Thanks:

Binod Suman

Saturday, June 5, 2010

How to use and install Yourkit, Java Profiler with YourKit



Java Profiling:

In software engineering, program profiling, software profiling or simply profiling, a form of dynamic program analysis, is the investigation of a program's behavior using information gathered as the program executes. The usual purpose of this analysis is to determine which sections of a program to optimize - to increase its overall speed, decrease its memory requirement or sometimes both.


There are many profiler are available in the market for Java. But I use yourkit java profile and going to step by step setup.


How you can profile your java application using yourkit Java profiler.


1. Download yourkit java profiler from here. You can download trial version for 2 weeks and see the website for more information.
2. During installation it will ask path to insatll the yourkit. Give any path but without space like c:\yourkit
3. Create one small project in Eclipse say(JavaTest)
4. Create one simple Java file to check in profiler say (App.java)


App.java
package com.binod.suman;


/**
* Author @ Binod Suman
*/


public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
App test = new App();
test.check();
}


public void check(){
String name="Binod";
System.out.println(getName(name));
}


public String getName(String s){
System.out.println("YES :: "+s);
for(int i=0;i<10000;i++){
try { Thread.sleep(1000); }
catch (InterruptedException e) { e.printStackTrace(); }
System.out.println(s);
} return s;
}
}

5. First start the yourkit. (Start -> All Programs -> Yourkit java profiler -> Yourkit java profiler .
The profiler can automatically detect all locally running profiled applications. If more than one is found, you will be asked to select one. If only one application is found, the profiler will connect to it without prompting you.


6. Now run your App.java now see the YourKit Profiler

It will show one Application runnig (com.binod.suman.App) started without profiler. If you will double click on the application,


YourKit will show one error message that The application cannot be profiled because it has not been started with the profiler.


So, now how you will connect your application with YourKit profiler

1. In Eclispe, right click on the mail java file (App.java) -> Run As -> Run Configurations ... -> Go to Second Tab Argumetns -> Go to VM arguments: and paste
-agentpath:C:\yourkit\bin\win32\yjpagent.dll
click on Apply then Run.

Next time onward no need to do all these thing, just run it.


Now come to Yourkit profiler this time it will show Started with profiler
Now you can double click on your application (App) and it will show all the CPU, Thread, Memory, Deadloccks, Garbage Collection, Summary details of the your application.

Source

Thanks .......... :)

Monday, March 29, 2010

VXML Getting Started, VXML fundamental, VXML easy example

VXML (=Voice XML)
Ref: http://www.ibm.com/developerworks/library/wa-voicexml/


Java is very famous for develop web application. In web application we will have UI and we can enter any dataor fetch data using that UI. Nowadays Phone or mobiel are very common, so we should have some technology to access our java code using the mobile and that is called VXML technology.


A simple VXML page (Say First.vxml)
<?xml version="1.0" encoding="UTF-8"?>
<vxml version="2.1">
<form>
<block>
<prompt> Hi Binod your first VXML Applciationi is working fine, Congratulations. </prompt>
</block>
</form>
</vxml>

Save this file say (D:\Binod)

You can check your vxml syntax here at cafe.bevocal.com. First need registration then you can check your code here itself. Really very nice.

To access this file, we have to upload this file for publically accessible. Some vxml interpreter should be thereto understand all vxml tags. The famous server is telco server. But to run vxml example from home or for learing purposem, we can use https://evolution.voxeo.com/ site.
Unlike traditional Web applications, you can't just open up a Web browser and surf on over to your VXML file; at least, not if you want a voice response. To test out a phone-based application, you obviously need a phone, and that implies a number to call. There are plenty of high-dollar approaches to mapping numbers to VoiceXML applications, but for testing, staging, and development, Voxeo offers a great free mapping service.
Navigate over to http://evolution.voxeo.com/,create username and password and log in (using the fields on the upper left side of the page). Under Account menu, select File, Logs, & Report option -> doulbe click on www -> go to first upload file secion and click on Browse and choose d:\Binod\First.vxml click open. Now click on Upload button.
Again click on Account menu then click on Application Manager ->

Add Application Give any name to your application say Binod_First_IVRThen click on Voice Phone Calls option, DONT change any option in voice application type. in Voice URLclick on file manager hyperlink you will be getting here your uploade file First.vxml, select this fileand click on map button. DONOT change any thing in Phone number combo box. Simple click on Create Application button.

You will be getting one mail to your mail box. :)

click on Contact Methods tab.copy Skype voip number and dial same number from your skype account.(If you dont have skype account then please go to http://www.skype.com/ and download skype and create one account then only you will be able to call this number).

If you want to edit your vxml file then Account -> Aplication Manager -> click on Binod_First_IVR, click on edit file (option is near to * Voice URL)Once file will get open you can change and just click on save change. Now you can check your new update after calling from skype.

For debugging: Account -> Application Debugger now call from skype then data will be show here in debugger.

Some other example on Input.
Second.vxml

<vxml version="2.1">
<property name="inputmodes" value="dtmf"/>
<form id="mainmenu">

<field name="xx" type="digits">
<prompt>
welcome to ivrs process BY Binod.
Please select the desired language.
press 1 for english.
press 2 for HINDI.
</prompt>

<filled>

<if cond="xx==1"> <prompt> YOU HAVE ENTERD ENGLISH </prompt> <elseif cond="xx==2"/> <prompt> YOU HAVE ENTERD HINDI </prompt> <else/> <prompt> Please choose correct option </prompt>
</if>
</filled>
</field>
</form>
</vxml>

Some more advacne input program.

If user does not give correct input then it should repromt for 3 times.

<vxml version="2.1">
<property name="inputmodes" value="dtmf"/>
<form id="mainmenu">
<field name="xx" type="digits">
<prompt>
welcome to TecnoTree IVR.
Please select the desired language.
press 1 for english.
press 2 for HINDI.
</prompt>
<filled>

<if cond="xx==1">
<prompt> YOU HAVE ENTERD ENGLISH </prompt>
<elseif cond="xx==2"/> <prompt> YOU HAVE ENTERD HINDI </prompt> </if> </filled> </field>
<noinput>
<prompt> We didnt get any input from you </prompt>
<reprompt/>

</noinput>
<nomatch>
<prompt> not a valid input</prompt> <reprompt/> </nomatch>

<nomatch count="3">
<prompt> You have reached maximum tried</prompt> <exit/> </nomatch>
</form>
</vxml>
This will only work for * or # incase of no match.

Another Example:
Take one input and prompt same number:

<vxml version="2.1">
<property name="inputmodes" value="dtmf"/>
<form id="mainmenu">
<field name="xx" type="digits">

<prompt> Enter any digit </prompt>
<filled>
<prompt> you have entered <value expr="xx"/> </prompt> </filled>
</field>
</form>
</vxml>

calculator.vxml

<vxml version="2.1">
<property name="inputmodes" value="dtmf"/>
<form id="mainmenu">
<var name="x" expr="0"/>
<var name="y" expr="0"/>
<!-- <var name="zz" expr="0"/> -->
<field name="xx" type="number">
<prompt>Welcome to IVR Calculator. Enter any digit </prompt>

<filled>
<assign name="x" expr="xx"/>
<prompt> you have entered <value expr="xx"/> </prompt>
<goto nextitem="yy"/>
</filled>
</field>

<field name="yy" type="number">
<prompt> <break time="2s"/> Enter Second any digit </prompt> <filled> <assign name="y" expr="yy"/>
<script>
var zz= Number(x)+Number(y);
</script>
<prompt> you have entered Second digit <value expr="yy"/>
<!-- Now the total value <value expr="xx+yy"/> -->
</prompt>
<!-- <assign name="zz" expr="Number(x)+Number(y)"/> --> <prompt> <break time="2s"/> The Answer after addition two number is <value expr="zz"/> </prompt>
</filled>
</field>

<field name="again" type="number">
<prompt> <break time="1s"/>
Press 1 for add another number.
Press 2 for exit.
</prompt>
<filled>
<if cond="again==1"> <prompt> YOU HAVE SELECTED ONE </prompt> <goto nextitem="xx"/>
<elseif cond="again==2"/> <prompt> YOU HAVE SELECTED TWO </prompt> <exit/>
</if>
</filled>
</field>
</form>
</vxml>

Recording Example
<?xml version="1.0" encoding="UTF-8"?>
<vxml version = "2.1">
<form id="F1">
<record name="R_1" beep="true" dtmfterm="true">
<prompt> Good Morning. Welcome to Binod Suman IVR. You can record your message after hear beep.
</prompt>

<prompt> after you are finished, Please press hash button </prompt>

<filled> <log expr="R_1$.duration"/> <log expr="R_1$.termchar"/> <log expr="R_1$.size"/>
<prompt> your recording was <value expr="R_1"/> THANK YOU FOR USING BINOD IVR APPLICATION. </prompt> </filled>
</record>
</form>
</vxml>