Re: Servlet To Java Application Communication

From: Anast (anastasiosm_at_hotmail.com)
Date: 04/13/04

  • Next message: vivienne wykes: "Re: long order_id = ((org.gjt.mm.mysql.PreparedStatement)statement).getLastInsertID();"
    Date: 13 Apr 2004 14:41:49 -0700
    
    

    "Silvio Bierman" <sbierman@idfix.nl> wrote in message news:<407bf09b$0$560$e4fe514c@news.xs4all.nl>...
    > "Anast" <anastasiosm@hotmail.com> wrote in message
    > news:a993bdfe.0404101939.28861f72@posting.google.com...
    > > Hi all,
    > >
    > > Firstly, I would like to write a Java servlet that it will be able to
    > > connect with a database (mySQL) and search its contents (using JDBC).
    > > Then, I would like to build a java application (NOT an applet), so
    > > that it would be able to search for queries the database, and display
    > > the results. Have you got any working examples that demonstrate the
    > > previous described functionality or any similar? I have installed
    > > Tomcat with MySQL Connector/J and MySQL in my box and work fine. Any
    > > help would be appreciable.
    > >
    > > Many thanks in advance.
    >
    > In spite of other remarks there is nothing unusual or undesirable about what
    > you are planning to do...
    >
    > Look at the URL class. It allows you to do a HTTP GET or POST which is the
    > way to communicate with a servlet. If you plan to do SOAP requests you
    > probably know you should encode the request XML in the body part of a POST
    > and expect the response XML in the response content.
    >
    > Servlet side:
    > -implement doPost(request,response)
    > -use request.getInputStream to read the request-body.
    > -use request.getOutputStream to write the response.
    >
    > Application(client) side:
    > URL url = new URL("http://someserver:someport/somepath");
    > URLConnection con = url.openConnection();
    > con.setDoOutput(true);
    > con.setDoInput(true);
    > con.setUseCaches(false);
    > OutputStream out = con.getOutputStream();
    > //use out to write the request
    > out.close();
    > InputStream in = con.getInputStream();
    > //use in to read the response
    > in.close();
    >
    > You can use this construct do do ny type of (HTTP or HTTPS) communication.
    > You can exchange strings, raw bytes, XML or even serialized Java objects
    > this way. Using SOAP is fine when going cross-app/cross-language, it is
    > somewhat bloated in other situation but if you want you can support several
    > protocals off course.
    >
    > Consider using GZIP encoding if requests/responses tend to get big and you
    > might want to support narrow bandwidths.
    >
    > Good luck,
    >
    > Silvio Bierman

    I'm glad to hear that there is nothing unusual about what I'm planning
    to do:) I ll try your structure.
    Thank you very much Silvio.


  • Next message: vivienne wykes: "Re: long order_id = ((org.gjt.mm.mysql.PreparedStatement)statement).getLastInsertID();"

    Relevant Pages

    • Re: execute js function
      ... I have a js file that will call a java servlet, ... This response is in XML format between tag. ... Successively in the js i will read the msg node ...
      (comp.lang.javascript)
    • Re: Request for suggestions re: architecture of IntraNet/Socket app[s]
      ... Your Ajax routine could be used to call an ISAPI dll from the browser, ... Here is the Simple Java Servlet ... @param request servlet request ... @param response servlet response ...
      (borland.public.delphi.non-technical)
    • Re: post to form from servlet
      ... You send an appropriate HTTP message from the one servlet to the other, ... and receive the response. ... Depending on the original request and the servlets' requirements, ... performing a post or outputting HTML -- it is the servlet that could do ...
      (comp.lang.java.programmer)
    • Re: Datei =?iso-8859-1?Q?=FCber?= Objectstream senden, Filereader
      ... >> Du kannst doch den Text komplett als response schicken ... >> Ich mal nehme an Applet fragt ... >> Da kommt dann genau das raus was das servlet reinschreibt. ... > den Graph als Object erzeugen. ...
      (de.comp.lang.java)
    • Re: Datei =?UTF-8?B?w7xiZXI=?= Objectstream senden, Filereader
      ... > Ich mal nehme an Applet fragt ... Ich benutze das Oreily Package aus dem Servlet Book ... den Graph als Object erzeugen. ... wie genau ich jetzt diesen Response ...
      (de.comp.lang.java)