2 Replies - 4080 Views - Last Post: 18 March 2009 - 09:07 PM Rate Topic: -----

#1 nila  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 156
  • Joined: 05-January 08

retrieving the nth element from arraylist

Post icon  Posted 18 March 2009 - 05:14 AM

Hi,
Following is my code:
public class ManagerEventServlet extends HttpServlet //implements ManagerEventListener 
{
	Statement st;Statement st1;
	ResultSet rs=null;ResultSet rs1=null;ResultSet rs2=null;ResultSet rs3=null;ResultSet rs4=null;String extension;int count;
	Connection conn = null;String uniqueid;String uniqueid2;String causetxt;String causecode;String callerid;
String ratio1;String a;
 String campaign1; String extnum;
 private ManagerConnection managerConnection;
 public void doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException, IOException 
 {
	 PrintWriter out = response.getWriter();
	 HttpSession session = request.getSession(true);
	 campaign1="aircel";//session.getAttribute("campaign").toString();
		ratio1="2";//session.getAttribute("ratio").toString();	 
try
{
	  Class.forName("com.mysql.jdbc.Driver").newInstance();
		conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/peopletech", "meetme", "meetme");
		st = conn.createStatement(); 
		ManagerConnectionFactory factory = new ManagerConnectionFactory(
				 "192.168.1.101", "admin", "amp111");
		this.managerConnection = factory.createManagerConnection();
			CommandAction commandAction;			
				commandAction=new CommandAction("show channels");
			managerConnection.login();
			CommandResponse res = (CommandResponse) managerConnection.sendAction(commandAction);
			for (String line : res.getResult())
			{
				
			
				List<String> allValues = new ArrayList<String>(); 
	
	 String channel=line.substring(0,line.indexOf(" "));
	
	 allValues.add(channel); 
	 for(int i=0; i < allValues.size();i++)
	 {  
		 System.out.println(allValues.get(i));  
	 }	   

			}
	 		managerConnection.logoff();
}
catch(Exception e)
{
	e.printStackTrace();
}
//response.setHeader("Refresh", "1");
 } 
}



the output is:

Quote

channel
Sip/5101
sip/5102
.
.
.
2 active channels
1 active calls


I need to get only the active channels and store it in database.But the active channels statically comes before the active calls.please help me to do this

thanks

Is This A Good Question/Topic? 0
  • +

Replies To: retrieving the nth element from arraylist

#2 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2720
  • View blog
  • Posts: 11,438
  • Joined: 20-September 08

Re: retrieving the nth element from arraylist

Posted 18 March 2009 - 08:09 AM

Why not substring it on 'active call'?
Was This Post Helpful? 0
  • +
  • -

#3 nila  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 156
  • Joined: 05-January 08

Re: retrieving the nth element from arraylist

Posted 18 March 2009 - 09:07 PM

Thanks for your reply.It helps me.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1