URL url = new URL(/* some destination */);
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setUseCaches(false);
connection.setRequestProperty("Content-Type", "application/x-java-serialized-object");
ObjectOutputStream out = new ObjectOutputStream(connection.getOutputStream());
out.writeObject(message);
out.flush();
out.close();
BufferedInputStream bis = new BufferedInputStream(connection.getInputStream());
Reader reader = new InputStreamReader(bis);
StringBuffer sb = new StringBuffer("");
int read; byte [] buffer = new byte[1024]; while ((read = bis.read(buffer)) != -1) { sb.append(new String(buffer)); }
Is this helpful? Why not use your logger to find out what is up?
At 11:27 PM 4/15/2004, Johan Wasserman - CPX Mngd Services wrote:
I need to serialize the session and save it to a blob in MySql (i use Hibernate).
I have tried, for example; ... ByteArrayOutputSream baos = new ByteArrayOutputstream(); ObjectOutputStream oos = new ObjectOutputStream(boas); oos.writeObject(session); //<-- it fails here, nothing in the logs byte[] sessionAsBytes = baos.toByteArray(); ...
I need this to give the user the option to restore a previous session (where they where before they last logged out, with all the session variables required to restore to that point).
Thanks, Johan.