Corporation Server User Manual
Classes and Methods
SIP Servlets 2-11
Example 2–3 Accessing Parameters in SipURI
// Create a SipURI, set the port, the lr, and the transport
// protocol parameter
SipURI myURI;
myURI = sipFactory.createSipURI("bob", "10.0.0.10");
myURI.setPort(5072);
myURI.setLrParam(true);
myURI.setTransportParam("udp");
Address
SIP addresses found in headers, such as the From, To, and Contact headers, are stored
as javax.servlet.sip Address objects. As shown in
Example 2–4, the object
holds, beside the URI, an optional display name and a set of name-value parameters.
Example 2–4 SIP Addresses Stored in java.servlet.sip Address Objects
Address contactAddress;
String displayName;
try
{
// Get the contact address
contactAdress = req.getAddressHeader("Contact");
displayName = contactAdress.getDisplayName();
}
catch (ServletParseException spe)
{
// Handle exception
}
// Create a new address
Address myNewAddress;
myNewAddress = sipFactory.createAddress(URI, "Bob's display name");
myNewAddress.setParameter("myparameter","42");
The content of myNewAddress in the preceding example is as follows:
DisplayName: "Bob’s display name"
URI: <sip:bob@example.com;lr>;
parameter myparameter: 42
The Address class offers the following methods:
■ getDisplayName()
■ setDisplayName()
■ getURI()
■ setURI()
■ clone()
■ toString()
SIP Details
When working with the SIP Servlet API, many SIP details are hidden and performed
automatically by the OCMS SIP Application Server.
■ When the transport protocol is UDP, retransmissions are handled automatically.