Hi,

Sorry about that - but I thought I had attached the
following code snippet.

When the chat user posts new message on the chat board, the message in
converted into a Properties object and posted onto the URL as follows -


Properties props = new Properties();
        props.put("message",message);
        sendPostMessage(props);


public InputStream sendPostMessage(Properties args) throws IOException {

        String argString = "";
        if(args != null)
        {
                argString = toEncodedString(args); //Converts into URL
                                                   //encoded data
        }
        URLConnection con = servlet.openConnection();
        con.setDoInput(true);
        con.setDoOutput(true);

        con.setUseCaches(false);

        con.setRequestProperty("Content-Type","application/x-www-form-urlencode
d");

        DataOutputStream out = new DataOutputStream(con.getOutputStream());
        out.writeBytes(argString);
        out.flush();
        out.close();
        return con.getInputStream();
}

public String toEncodedString(Properties args)
{
        StringBuffer buf = new StringBuffer();
        Enumeration names = args.propertyNames();
        while(names.hasMoreElements())
        {
        String name = (String)
names.nextElement();
                String value = args.getProperty(name);
                buf.append(URLEncoder.encode(name) + "=" +
URLEncoder.encode(value));
                if(names.hasMoreElements()) buf.append("&");
        }
        return buf.toString();
}

--------------------------------------------------------------------------

Hope you can help...

Samian

> Hi all,
>
> I am trying to use servlet - applets to get a chatsession(ref - OReilly
> book on Servlets) .
>  The problem arises when I try to run the applet in Netscape. For some
> reason, the post command doesnot seem to work in Netscape. I am rather
> stumped here.
> ANY IDEAS would be appreciated!

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to