SIP Servlet 示例之 Call Forward

Servlet将收到的请求转发到指定的URI。

import java.io.IOException;
import javax.servlet.sip.*;
import javax.servlet.*;

public class CallForward extends SipServlet {
SipURI m_target = null;

SipFactory m_sipFactory;

public void init() throws ServletException {
m_sipFactory = (SipFactory) getServletContext().getAttribute(
"javax.servlet.sip.SipFactory");

String forwardURI = (String) getInitParameter("target-uri");
m_target = (SipURI) m_sipFactory.createURI(forwardURI);
}

public void doRequest(SipServletRequest req)
throws TooManyHopsException {
log(req.toString());
// ...
req.getProxy().proxyTo(m_target);
}

public void doResponse(SipServletResponse resp) throws IOException {
log(resp.toString());
// ...
}
}

你可能感兴趣的:(servlet)