JSP and JavaBean
Hi all
I am using following JSP page to send the command to RFID reader and getting response from the reader.
<%@ page language="java" %>
<%@ page import="java.util.*"%>
<jsp:useBean id="readerIF5" class="RFIDReaders.IF5.IF5Reader" scope="session"/>
<jsp:setProperty name="readerIF5" property="*"/>
<%
// Sending commands to reader
String comm ="READ ANT COUNT REPORT=EVENT";
readerIF5.ReadIF5(comm);
%>
<%
// Getting tag data from reader
String Data = readerIF5.getData();
out.println(Data);
%>
<jsp:include page="sendIF5.jsp" />
Following is javabean
package RFIDReaders.IF5;
import com.intermec.datacollection.rfid.BasicBRIReader;
import com.intermec.datacollection.rfid.BasicReaderEvent;
import com.intermec.datacollection.rfid.BasicReaderException;
import com.intermec.datacollection.rfid.BasicTagEventListener;
import javax.servlet.http.*;
publicclass IF5Readerimplements HttpSessionBindingListener{
private String IP;
private String portStr;
private String Address;
String DATA;
String Command;
BasicBRIReader IMacReader =new BasicBRIReader();
/**
* Constructor
*/
public IF5Reader(){
}
/*
* Connect method to mak connection with IMac Reader..
*/
publicvoid ConnectIF5(String address){
try{
IMacReader.open(address);
}
catch(BasicReaderException ex){
ex.printStackTrace();
}
}
// Send command and get Tag Data.
String rData ="\n";
publicvoid ReadIF5(String Command)throws BasicReaderException{
IMacReader.addTagEventListener(new BasicTagEventListener(){
publicvoid tagEvent(BasicReaderEvent Event){
rData += Event.getTagDataString() +"\n";
setData(rData);
}
});
try
{
IMacReader.execute(Command);
Thread.sleep(1000);
}
catch(InterruptedException e){
e.printStackTrace();
}
}
// Response from Reader.
public String simpleRead(String Address, String cmd){
String Response =null;
try
{
ConnectIF5(Address);
Response = (IMacReader.execute(cmd));
}
catch (BasicReaderException ex)
{
ex.printStackTrace();
}
return Response;
}
// Setting tag data string.
privatevoid setData(String DATA){
this.DATA = DATA;
}
// Getting tag data string.
public String getData(){
return DATA;
}
// Closing Reader connection.
publicvoid CloseIF5(){
try{
IMacReader.removeTagEventListener(null);
IMacReader.close();
}
catch(BasicReaderException ex){
ex.printStackTrace();
}
}
publicvoid valueBound(HttpSessionBindingEvent evt){}
publicvoid valueUnbound(HttpSessionBindingEvent evt){}
}
Now my problem is that when its prints data it did not clear the old data but it prints old as well as new data.
I mean if send the commnad first time it print as follows
H02000000000000000151F503 1 1 H02000031323334000151E62B 1 1
and if i send the command again, we can see below that it prints old data (bold) as well as new data together.I just want to clear the old data and prints only the new data.H02000000000000000151F503 1 1 H02000031323334000151E62B 1 1 H02000031323334000151B775 1 1 H02000000000000000151F503 1 1
H02000000000000000151F503 1 1 H02000031323334000151E62B 1 1
H02000031323334000151E62B 1 1
Thanx
kvijai

