0 Replies Latest reply on Nov 15, 2005 1:03 AM by Jubin Kuriakose

    applet servlet communication

    Jubin Kuriakose Newbie

      Hi all,
      I am trying out applet servlet communication and the applet is invoking the servlet but the responcse i get is a IO exception

      Server returned HTTP response code: 405 for URL:http://localhost:8080/applet/servlet/DaytimeServlet.

      Here is my servlet code

      public class DayTimeServlet extends HttpServlet {
      
       public DayTimeServlet() {
       super();
       // TODO Auto-generated constructor stub
       }
      
      
       public Date getDate(){
       return new Date();
       }
      
      
       protected void doGet(HttpServletRequest req, HttpServletResponse resp)
       throws ServletException,
       IOException {
       super.doGet(req, resp);
       System.out.println("doGet called with date-->" + getDate().toString());
       resp.setContentType("text/plain");
       PrintWriter out = resp.getWriter();
       out.println(getDate().toString());
      
       //out.flush();
       //out.close();
       }
      
       protected void doPost(
       HttpServletRequest request,
       HttpServletResponse response) throws ServletException, IOException {
       // TODO Auto-generated method stub
       System.out.println("doPost called");
       doGet(request,response);
      
       }
      
      }


      and here is the piece of code that connects to the se4rvlet from the applet
       public InputStream sendGetMessage(Properties args) throws IOException {
      
       String argString = ""; // default
      
       if (args != null) {
       argString = "?" + toEncodedString(args);
       }
       URL url = new URL(servlet.toExternalForm() + argString);
      
       // Turn off caching
       URLConnection con = url.openConnection();
       con.setUseCaches(false);
       con.connect();
       InputStream in = con.getInputStream();
       if(in == null)
       JOptionPane.showMessageDialog(null,"Inputstream is null");
       return in;
       }
      

      This method throws an IOException...
      Thanks for all the help in advance
      jubs