try
{
URL codeBase = getCodeBase();
URL url = new URL("http", codeBase.getHost(), codeBase.getPort(),
"/amdi/Image");
JOptionPane.showMessageDialog(null, url);
URLConnection connection = url.openConnection();
//informa o tipo da conexão
connection.setDoOutput(true);
//não usa cache na conexão de URL
connection.setUseCaches(false);
connection.setDefaultUseCaches(false);
//seta o valor do header Content-Type para octet-stream
connection.setRequestProperty("Content-Type",
"application/octet-stream");
//cria o stream para enviar as informações
ObjectOutputStream out = new
ObjectOutputStream(connection.getOutputStream());
//envia o objeto e fecha a conexão
out.writeObject(objetoEnviado);
out.flush();
out.close();
}
catch(MalformedURLException e)
... ... ... ... ... ... ... ... ... ...
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
try
{
log("Gravação de arquivo");
//faz a leitura dos dados enviados através da web
ObjectInputStream input = new
ObjectInputStream(request.getInputStream());
Vector informacoes = (Vector) input.readObject();
input.close();
... ... ...
synchronized(this)
{
//cria um arquivo e insere os dados nele
FileWriter fileOut = new
FileWriter("arquivos/nomeArquivo");
fileOut.write(informacoes.elementAt(0) );
... ... ...
fileOut.flush();
fileOut.close();
}// end synchronized
}
catch(Exception e)
{
log(e.getMessage());
}
}
O que estou fazendo errado?
