Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Servlets
|
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Servlets section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 28th, 2005, 04:59 AM
Registered User
 
Join Date: Nov 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Calling a command from a servlet

I'm trying to call a SIPp command from a servlet, this is the response I should get:

Resolving 193.5.226.181...
------------------------------ Scenario Screen -------- [1-4]: Change Screen --
  Call-rate(length) Port Total-time Total-calls Remote-host
  10.0(0 ms)/1.000s 5061 0.00 s 0 193.5.226.181:5060(UDP)

  0 new calls during 0.000 s period 0 ms scheduler resolution
  0 concurrent calls (limit 30) Peak was 0 calls, after 0 s
  0 out-of-call msg (discarded)
  1 open sockets

                                 Messages Retrans Timeout Unexpected-Msg
      INVITE ----------> 0 0
         100 <---------- 0 0 0
         180 <---------- 0 0 0
         200 <---------- E-RTD 0 0 0
         ACK ----------> 0 0
        INFO <---------- 0 0 0
         200 ----------> 0 0
        INFO ----------> 0 0
         100 <---------- 0 0 0
         180 <---------- 0 0 0
         200 <---------- E-RTD 0 0 0
        INFO <---------- 0 0 0
         200 ----------> 0 0
        INFO <---------- 0 0 0
         200 ----------> 0 0
             [ 1000 ms]
         BYE ----------> 0 0 0
         200 <---------- 0 0 0
------ [+|-|*|/]: Adjust rate ---- [q]: Soft exit ---- [p]: Pause traffic -----




And if I launch the servelt I get this:
Resolving 193.5.226.181...
And the other part is somehow kicked out.
I'm using the Tomcat application server


 
Old December 23rd, 2005, 11:33 AM
Authorized User
 
Join Date: Dec 2005
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Put this snippet in your servlet:

Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec("SIPp"); // or whatever
InputStream is = process.getInputStream();
OutputStream os = response.getOutputStream();

int data = 0;
while((data = is.read()) != -1)
{
    os.write((char)data);
}
response.setContentType("text/plain");


Just invoke this servlet and you should see the output
on the browser

________
Adarsh






Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in calling classes in simple Servlet sanna231 J2EE 6 December 23rd, 2012 01:06 AM
Calling java Servlet from ascx page pradeepnair74 BOOK: ASP.NET AJAX Programmer's Reference : with ASP.NET 2.0 or ASP.NET 3.5 ISBN: 978-0-470-10998-4 0 October 7th, 2008 07:31 AM
calling a java servlet from a asp.net page dub_beat ASP.NET 2.0 Basics 0 April 2nd, 2007 08:31 PM
calling a servlet by clicking a menu? pandian Servlets 1 February 4th, 2006 10:28 AM
calling java servlet from javascript bearfacts Javascript How-To 1 August 26th, 2004 04:57 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.