ResponderServlet.java
Upload User: liulanlin
Upload Date: 2017-12-08
Package Size: 1274k
Code Size: 6k
Category:

VOIP program

Development Platform:

Java

  1. /*
  2.  * Created on Apr 14, 2004
  3.  *
  4.  * To change the template for this generated file go to
  5.  * Window>Preferences>Java>Code Generation>Code and Comments
  6.  */
  7. package gov.nist.applet.phone.webapp.phone;
  8. import java.io.IOException;
  9. import java.io.PrintWriter;
  10. import javax.servlet.ServletContext;
  11. import javax.servlet.ServletException;
  12. import javax.servlet.http.HttpServlet;
  13. import javax.servlet.http.HttpServletRequest;
  14. import javax.servlet.http.HttpServletResponse;
  15. /**
  16.  * @author root
  17.  *
  18.  * To change the template for this generated type comment go to
  19.  * Window>Preferences>Java>Code Generation>Code and Comments
  20.  */
  21. public class ResponderServlet extends HttpServlet {
  22. public void doGet (HttpServletRequest request,HttpServletResponse repsonse) throws ServletException,IOException{
  23. //use of the responder
  24. //count the users
  25.    ServletContext applicationContext=this.getServletContext();
  26.    if(applicationContext.getAttribute("users")==null)  
  27.    applicationContext.setAttribute("users",new Integer(0));
  28.    int users=((Integer)applicationContext.getAttribute("users")).intValue()+1;
  29.    applicationContext.setAttribute("users",new Integer(users));
  30.    PrintWriter out=repsonse.getWriter();
  31. out.println(
  32. "<HTML>" + " <HEAD>" + " <TITLE>>Jain Sip Applet Phone</TITLE>" + " </HEAD>" + "       <table border="0" cellspacing="0" cellpadding="0" width="100%">   " + "         <tr>" + " <td width="554" ><img src="nisthome_banner.jpg" ></td>" + " <td background="nisthome-bg.jpg"> &nbsp;</td>" + "   </tr>" + "   <tr>" + " <td width="554" > <img src="main-image.jpg" ></td>" + " <td background="main-bg.jpg"> &nbsp;</td>" + "   </tr>" + "   <tr>" + " <td width="554" > <img src="bottom-bar.jpg" border="0" ></td>" + " <td background="bottom-bg.jpg"> &nbsp;</td>" + "      </tr>" + " </table>" + "<BODY bgcolor="#333333" text="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"" + "link="white" alink="white" vlink="red">" + " <center>" +
  33. " <p>This application requires JMF, if you don't have it please install it from this there :<br>" +
  34. " <a href="http://java.sun.com/products/java-media/jmf/2.1.1/download.html">" +
  35. " http://java.sun.com/products/java-media/jmf/2.1.1/download.html</a><br>" + " <p>If you're experiencing some problems viewing the applet,check your java plug-in control panel :<br>" + " - In the Proxies tab, uncheck the "Use browser Settings" box <br>" + " - In the Cache tab, uncheck the "Enable Caching" box<br>" + " <br><br>" + " <APPLET NAME="SipResponder"" + " CODE="gov/nist/applet/phone/ua/gui/NISTMessengerApplet.class"" + " ARCHIVE="applet-phone.jar"" + " WIDTH=320 HEIGHT=520 MAYSCRIPT="true">" + " <param name="PROXYADDRESS" value=""+request.getLocalAddr()+"">" + " <param name="PROXYPORT" value="4000">" + " <param name="SIGNALINGTRANSPORT" value="tcp">" + " <param name="MYADDRESS" value=""+request.getRemoteAddr()+"">" + " <param name="SERVERADDR" value=""+request.getLocalAddr()+"">" + " <param name="SERVERPORT" value=""+request.getServerPort()+"">" + " <param name="RESPONDER" value="true">" + " <param name="MEDIATRANSPORT" value="tcp">" + " <param name="USERURI" value="user"+users+"@nist.gov">" + " Your browser is completely ignoring the &lt;APPLET&gt; tag!" + " </APPLET>" + " </center>" + "</BODY>" + "</HTML>");
  36.      
  37. }
  38. public void doPost(HttpServletRequest request,HttpServletResponse repsonse) throws ServletException,IOException{
  39. //use of the responder
  40. //count the users
  41. ServletContext applicationContext=this.getServletContext();
  42. if(applicationContext.getAttribute("users")==null)  
  43. applicationContext.setAttribute("users",new Integer(0));
  44. int users=((Integer)applicationContext.getAttribute("users")).intValue()+1;
  45. applicationContext.setAttribute("users",new Integer(users));
  46. PrintWriter out=repsonse.getWriter();
  47. out.println(
  48. "<HTML>" +
  49. " <HEAD>" +
  50. " <TITLE>>Jain Sip Applet Phone</TITLE>" +
  51. " </HEAD>" +
  52. "       <table border="0" cellspacing="0" cellpadding="0" width="100%">   " +
  53. "         <tr>" +
  54. " <td width="554" ><img src="nisthome_banner.jpg" ></td>" +
  55. " <td background="nisthome-bg.jpg"> &nbsp;</td>" +
  56. "   </tr>" +
  57. "   <tr>" +
  58. " <td width="554" > <img src="main-image.jpg" ></td>" +
  59. " <td background="main-bg.jpg"> &nbsp;</td>" +
  60. "   </tr>" +
  61. "   <tr>" +
  62. " <td width="554" > <img src="bottom-bar.jpg" border="0" ></td>" +
  63. " <td background="bottom-bg.jpg"> &nbsp;</td>" +
  64. "      </tr>" +
  65. " </table>" +
  66. "<BODY bgcolor="#333333" text="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"" +
  67. "link="white" alink="white" vlink="red">" +
  68. " <center>" + " <p>This application requires JMF, if you don't have it please install it from this there :<br>" + " <a href="http://java.sun.com/products/java-media/jmf/2.1.1/download.html">" + " http://java.sun.com/products/java-media/jmf/2.1.1/download.html</a><br>" + " <p>To try the responder, just double click on the responder@nist.gov contact and" + " on the chat frame window click on audio, then record your voice...<br><br> "+
  69. " <p>If you're experiencing some problems viewing the applet,check your java plug-in control panel :<br>" +
  70. " - In the Proxies tab, uncheck the "Use browser Settings" box <br>" +
  71. " - In the Cache tab, uncheck the "Enable Caching" box<br>" +
  72. " <br><br>" +
  73. " <APPLET NAME="SipResponder"" +
  74. " CODE="gov/nist/applet/phone/ua/gui/NISTMessengerApplet.class"" +
  75. " ARCHIVE="applet-phone.jar"" +
  76. " WIDTH=320 HEIGHT=520 MAYSCRIPT="true">" +
  77. " <param name="PROXYADDRESS" value=""+request.getLocalAddr()+"">" +
  78. " <param name="PROXYPORT" value="4000">" +
  79. " <param name="SIGNALINGTRANSPORT" value="tcp">" +
  80. " <param name="MYADDRESS" value=""+request.getRemoteAddr()+"">" +
  81. " <param name="SERVERADDR" value=""+request.getLocalAddr()+"">" +
  82. " <param name="SERVERPORT" value=""+request.getServerPort()+"">" +
  83. " <param name="RESPONDER" value="true">" +
  84. " <param name="MEDIATRANSPORT" value="tcp">" +
  85. " <param name="USERURI" value="user"+users+"@nist.gov">" +
  86. " Your browser is completely ignoring the &lt;APPLET&gt; tag!" +
  87. " </APPLET>" +
  88. " </center>" +
  89. "</BODY>" +
  90. "</HTML>");
  91. }
  92. }