Hopefully this will help you. This is how I am doing it....
This is called to add a sourceName and sourceType to the db. A boolean is returned weither the action was successful or not. The code Integer indicates to the Servlet which function to use. My servlet houses many functions. I place a call to postObject to do the actual transfer (code at the bottom)
public Boolean addSource(String SourceName, String SourceType) throws Exception {
servlet = new URL(webBase,"servlet/AZUniversalServlet");
Integer code = new Integer(5);
Serializable objs[] = { code, SourceName, SourceType };
in = postObjects(servlet, objs);
Boolean result = (Boolean)in.readObject();
return result;
}
private ObjectInputStream postObjects(URL myServlet, Serializable myObjs[])throws Exception {
URLConnection con = servlet.openConnection();
con.setDoInput(true);
con.setDoOutput(true);
con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
ObjectOutputStream out = new ObjectOutputStream(con.getOutputStream());
int numObjects = myObjs.length;
for(int x= 0; x<numObjects; x++)
out.writeObject(myObjs[x]);
out.flush();
out.close();
return new ObjectInputStream(con.getInputStream());
}
Good Luck.
Todd