import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
/**
* This class is running
as a servlet accessible at URL http://192.168.1.3/ourDirectory.
* It was built to replace the last item in the list accessed through any Cisco
IP
* phone's 'Directories' key so that INRIA's LDAP directory can be accessed instead
* of CallManager's internal directory.
**/
public class ourDirectory extends HttpServlet {
PrintWriter outToClient;
// the only method to implement as a daughter class of HttpServlet
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
HttpSession session = request.getSession();
// content type must be set to "text/xml" so the IP phone can
// accept the answer
response.setContentType("text/xml");
// we need to write our answer back to the IP phone's request
// through this object
outToClient = response.getWriter();
System.out.println("Analysis of received Http request: ");
System.out.println("\tMethod : " + request.getMethod());
System.out.println("\tURL : " + HttpUtils.getRequestURL(request));
System.out.println("\tURI : " + request.getRequestURI());
System.out.println("\tParameters : " + request.getQueryString());
Enumeration e;
e = request.getHeaderNames();
System.out.println("\tHttp headers : ");
while (e.hasMoreElements()){
Object element = e.nextElement();
System.out.println("\t\t" + element + " : " + request.getHeader((String)element));
}
// now we have set the HTTP parameters of our respone, let's actually
// send INRIA's directory title and URL. The stream sent represents
// an XML menu object interpretable by the Cisco IP phone's navigator
outToClient.println("<CiscoIPPhoneMenu>");
outToClient.println("<Title>Directory Search" + "</Title>");
outToClient.println("<MenuItem>");
outToClient.println("<Name>Corporate Directory INRIA</Name>");
outToClient.println("<URL>http://192.168.1.3/directorySearchTool</URL>");
outToClient.println("</MenuItem>");
outToClient.println("</CiscoIPPhoneMenu>");
// finally, let's close the HTTP session
session.invalidate();
}
}
auteur : Philippe Sultan ------- date de mise à jour : 17 juillet, 2003