Title: RE: Calling a Servlet from an Applet

Sandy,

Applet CAN call  servlet/Jsp.  The trick is using URL class.  The following code is an applet which has a comboBox filled by city names provided by servlet. 

Hope this helps

Jeff

private void Get_Information_From_Sever(String tableName) throws MalformedURLException, IOException
    {

        URL  url = new URL( "http://localhost:8080/examples/servlet/info_feed?table=" + tableName);
                //?table=" + tableName);
                URLConnection con= url.openConnection();
                con.setUseCaches(false);
                InputStream in = con.getInputStream();
                DataInputStream textStream;
                textStream = new DataInputStream(in);
                String strLine = textStream.readLine();
            // test only
                //strLine = "   *Beijing*Berlin*Chicago*New York*Paris*London*";
               
                LoadtoComboBox(strLine, "*", choice_1);

        }
    private void LoadtoComboBox(String strInput, String strSeperator,java.awt.Choice  choiceBox)
    {
       String strTemp ;
           String strHold;
           String strNeed;

           strHold = strInput;
           int pos = strHold.indexOf( strSeperator );
           while (pos !=-1)
           {
                 strNeed = strHold.substring(0, pos);
                 strHold = strHold.substring(pos+1);
                 pos = strHold.indexOf( strSeperator ); 
                 choiceBox.addItem( strNeed );


           }


    }

-----Original Message-----
From: Sandy Tiu [mailto:[EMAIL PROTECTED]]
Sent: Monday, December 06, 1999 7:14 PM
To: [EMAIL PROTECTED]
Subject: Calling a Servlet from an Applet


Hi,

Can a Servlet be called from an Applet?
Thanks.

Sandy

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to