Re: [Asterisk-java-users] run originateAction from a jsp
Brought to you by:
srt
From: Stefan R. <sr...@re...> - 2006-01-15 02:20:18
|
sure you could put all the stuff in a static method and call that from your jsp. But I would rather suggest to not include any java stuff into a jsp at all. Any well architectured webapp separates view (jsp) and control and talking to Asterisk is certainly not part of the view... =3DStefan On Thu, 2006-01-12 at 16:30 -0600, g f wrote: > Hello all, > I am trying to run the following by calling it from a jsp. > The code below worksfine if I include a main and run it as an > executable. Is this doable or do I need to rethink my code. > Is it possible to create on method from the code below and call that > method only(include the connection in the run method)? > =20 > Thanks. > =20 > =20 > public class Test > { > private ManagerConnection managerConnection; > private String CHANNEL =3D "SIP/201"; //channel that will initiate > private String DATA =3D "SIP/202"; //channel that the initiater > will call=20 > private String CALLERID =3D "22222"; //set the caller id=20 > =20 > =20 > public Test() throws IOException > { > ManagerConnectionFactory factory =3D new > ManagerConnectionFactory(); > =20 > this.managerConnection =3D > factory.getManagerConnection("135.119.11.1", > "manager", "pa55w0rd"); > } > =20 > =20 > public void run(String channel, String data) throws IOException, > AuthenticationFailedException,=20 > TimeoutException > { > =20 > OriginateAction originateAction; > ManagerResponse originateResponse; > //set vars for dialing from one sip to another > originateAction =3D new OriginateAction(); > originateAction.setChannel(channel); > originateAction.setApplication("dial");=20 > originateAction.setActionId("dufus"); > originateAction.setData(data); > originateAction.setCallerId(CALLERID); > originateAction.setPriority(new Integer(1)); > originateAction.setTimeout(new Integer(30000)); > =20 > // connect to Asterisk and log in > managerConnection.login(); > =20 > // send the originate action and wait for a maximum of 30 > seconds for=20 > // Asterisk > // to send a reply > originateResponse =3D > managerConnection.sendAction(originateAction, 30000); >=20 > =20 > // and finally log off and disconnect > managerConnection.logoff (); > } >=20 |