This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Hi All,
I am very new to the servlet concept. I am trying to write an application which takes input (Non SIP non HTTP) on a socket & then converts it into SIP. Here is a scenario ....
1. My application will be listening on a socket say for example 7080 and will receive message.( Message simply contains To and from user name)
2. A generic servlet will get invoked which will construct a sip message using the caller-callee information sent in a simple string. ( I am not looking for any parsing to be done by container).
3. That generic servlet will then invoke a sip servlet.
Can somebody help me in designing this application.
you can write a Generic Servlet which will have 3 methods
a. init()
b. service()
c. destroy()
In init() method, you can write code which listens to port 7080
When ever a message is recieved on port 7080, control goes to service() method where you can construct sip message using the caller-callee information. Then control can be forwarded to SIPServlet with required information
In destroy() method, you can discontinue listening to port 7080 (closing the socket)
you can write a Generic Servlet which will have 3 methods
a. init()
b. service()
c. destroy()
In init() method, you can write code which listens to port 7080
When ever a message is recieved on port 7080, control goes to service() method where you can construct sip message using the caller-callee information. Then control can be forwarded to SIPServlet with required information
In destroy() method, you can discontinue listening to port 7080 (closing the socket)
~ abhay
Thanks a lot Abhay !!!
I have one doubt regarding the approach you suggested. As per specification of jsr289 and container manual, it says we should not spawn a new thread from servlet, as container manages the thread pool ( Please Correct me if i am wrong.
1. Will it be okay to spawn a thread from init ?
2. The thread that gets spawned through init() is container thread or an independent thread ( How can i verify this by looking at thread signature ...).
Thanks you
Regards,
Ankit Bhandari
Ankit Bhandari
Greenhorn
Joined: Dec 23, 2011
Posts: 9
posted
0
Hey Abhay,
I have one doubt regarding invoking service method. As you said, "When ever a message is received on port 7080, control goes to service() method " . Can you please help us in doing this. I am not able to invoke service from there.
service() -Dispatches client requests to the protected service method. There's no need to override this method.
No pain, No gain.
OCJP 1.6
Tim Moores
Rancher
Joined: Sep 21, 2011
Posts: 2407
posted
0
I'm not convinced that tackling this issue within the confines of the Servlet API is the right approach. The GenericServlet/HttpServlet distinction makes it sound as if every protocol could be handled simply by extending GenericServlet, whereas the API is actually geared very much towards request/response protocols like HTTP. Your problem sounds like it would be better handled by directly listening on a socket, and then making SIP requests from within that socket server.
Ankit Bhandari
Greenhorn
Joined: Dec 23, 2011
Posts: 9
posted
0
Tim,
Thanks for your reply. As you suggested, will it be okay to invoke a listening socket from container. Or i can make container to listen on a socket and deliver raw buffer to some servlet.
Thank you
Regards,
Ankit Bhandari
Tim Moores
Rancher
Joined: Sep 21, 2011
Posts: 2407
posted
0
Yes, you can open a ServerSocket from within a servlet container. Or you can create your own server that is independent of it. Not sure what you mean by "deliver to some servlet". Your server process would not be a servlet, no matter whether it runs inside the servlet container, or outside of it.