Re: Applet to servlet communication

From: Ike (rxv_at_hotmail.com)
Date: 10/23/03

  • Next message: Roelof Vuurboom: "QStudio for Java Enterprise 2.0 released"
    Date: Thu, 23 Oct 2003 00:06:25 GMT
    
    

    I believe in your URL you need the server to be "localhost" //Ike

    "Rui Pacheco" <ruipacheco@hotmail.com> wrote in message
    news:b03e6ccc.0310220802.6f1f4a12@posting.google.com...
    > Hello everyone
    >
    > I am writing an applet that connects to a database through a servlet.
    > For that I need to open an URL connection to the servlet and send
    > parameters to the servlet. I already do that, but the connection fails
    > to reach the servlet.
    > Both the servlet and the applet are on the same computer (my pc is the
    > test machine). Although the servlet wasn't designed to work with HTML,
    > if I do a GET to it through the browser's address bar I can see the
    > init() method being evoked in the server logs. When I send the exact
    > same string through the applet, nothing happens. No init(), no debug
    > messages, no exceptions, nothing.
    >
    >
    > Here's my applet code that handles the connection:
    >
    > String query_string = "?ano=" + URLEncoder.encode(
    > getParameter("ano"), "UTF-8" ) + "&mes=" + URLEncoder.encode(
    > getParameter("mes"), "UTF-8" ) + "&dia=" + URLEncoder.encode(
    > getParameter("dia"), "UTF-8" ) + "&user=" + URLEncoder.encode(
    > getParameter("utilizador"), "UTF-8" );
    >
    > //Write the new found data to the servlet
    > URL url = new URL( server + query_string );
    > URLConnection urlConnection = url.openConnection();
    >
    > //inform the connection that we will send output and accept input
    > urlConnection.setDoOutput(true);
    >
    > //Don't use a cached version of URL connection.
    > urlConnection.setUseCaches (false);
    > urlConnection.setDefaultUseCaches (false);
    >
    >
    >
    > My servlet is a standard servlet with doGet and doPost. Inside the
    > doGet I call a processRequest( response, reqiest ). Inside the process
    > request I have this:
    > System.out.println( request.getParameter("ano") );
    >
    >
    >
    > Has anyone seen anything like this before? I any help would be most
    > appreciated.
    > Thank you very much
    > Rui Pacheco


  • Next message: Roelof Vuurboom: "QStudio for Java Enterprise 2.0 released"

    Relevant Pages

    • Re: applet as servlet BACK end
      ... If I use a socket I'll use some dedicated port for the ... What I was afraid of was the fact that the applet will load from a web ... while the servlet runs on the SAME machine ... execution in the server, which is not what I want. ...
      (comp.lang.java.programmer)
    • servlet Socket.accept() method executes multiple times for a single connection
      ... In the server portion of the code that's shown below, ... I have listed the code for both the servlet and the applet below ... private String ServerName_; ...
      (comp.lang.java.help)
    • servlet/applet communication problem or Linux/Windows trouble ?
      ... frame contains a little form which has the servlet (running on my ... used to load a page with the applet. ... then the servlet listens on port 14444 ... until a connection request is received, and opens a clientSocket. ...
      (comp.lang.java.programmer)
    • Re: Http POST requests changed to GET by proxy?
      ... between the applet and the servlet engine. ... When our applet creates a HTTP connection to the server it uses ... unknown and creates an HTTP GET request, thus doGet will be called on ...
      (comp.lang.java.programmer)
    • Re: Applet to servlet communication
      ... I believe in your URL you need the server to be "localhost" //Ike ... > I am writing an applet that connects to a database through a servlet. ... I already do that, but the connection fails ...
      (comp.lang.java.help)