Hi, i communicating an applet to a servlet. In get request i make
request.getParameter("name_parameter") and i have no problems with that,
however in post requests i make the request.getParameter("name_parameter");
and i can't get it. It gives me the following error in Java Console
java.io.FileNotFoundException http://phc:8000/servlet?opcao=something
here is my code in applet side for get and send to servlet:
public void sendToServlet(Object obj, String opcao){
try {
//set up the connection for
URL url = new
URL("http://phc:8000/servicos?"+URLEncoder.encode("opcao")+
"="+URLEncoder.encode(opcao));
URLConnection uc = url.openConnection();
uc.setDoOutput( true );
uc.setDoInput( true );
uc.setUseCaches( false );
uc.setRequestProperty( "Content-Type",
"application/x-www-form-urlencoded" );
//send the object
ObjectOutputStream objOut = new ObjectOutputStream( new
GZIPOutputStream( uc.getOutputStream() ) );
objOut.writeObject(obj);
objOut.flush();
objOut.close();
//get response from doPost();
DataInputStream respIn = new DataInputStream( uc.getInputStream() );
if ( respIn.readBoolean() == true )
System.out.println("objectPost successful no servicos
Servlet");
else
System.out.println("objectPost() failed");
respIn.close();
}
catch ( java.io.IOException e )
{
System.out.println( e.toString() );
}
}
//**************************
public Object getFromServlet(String opcao, String
am){
Object obj = null;
try{
URL url = new
URL("http://phc:8000/servicos?"+URLEncoder.encode("opcao")+
"="+URLEncoder.encode(opcao)+"&"+URLEncoder.encode("param")+
"="+URLEncoder.encode(param));
URLConnection con = url.openConnection();
con.setDoOutput( true );
con.setDoInput( true );
con.setUseCaches( false );
con.setDefaultUseCaches(false);
InputStream in = con.getInputStream();
ObjectInputStream objStream;
objStream = new ObjectInputStream(in);
obj = (Object)objStream.readObject();
objStream.close();
in.close();
}catch(IOException o){o.printStackTrace();}
catch(ClassNotFoundException c){c.printStackTrace();}
return obj;
}
Thanks for your help.
Hugo Malheiro
___________________________________________________________________________
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