Posted By:
ilana_mush
Posted On:
Sunday, July 28, 2002 05:54 AM
Hi. I wrote a client (java class) that connects a servlet using a urlConnection. The client has different methods. In every method I put different parameters in the header (using connection.setRequestProperty("...","..."); when I tried to call one method after the other I got the following exception: Exception in thread "main" java.lang.IllegalAccessError: Already connected at sun.net.www.protocol.http.HttpURLConnection.setRequestProperty(HttpUR LConnection.java:851) My solution for the problem was to start the connection in every method, e.g. in the beginning of every method I wrote: try{ url=new URL(u
More>>
Hi.
I wrote a client (java class) that connects a servlet using a urlConnection.
The client has different methods. In every method I put different parameters in the header (using connection.setRequestProperty("...","...");
when I tried to call one method after the other I got the following exception:
Exception in thread "main" java.lang.IllegalAccessError: Already connected
at sun.net.www.protocol.http.HttpURLConnection.setRequestProperty(HttpUR
LConnection.java:851)
My solution for the problem was to start the connection in every method, e.g. in the beginning of every method I wrote:
try{
url=new URL(urlString);
connection = url.openConnection();
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setUseCaches(false);
connection.setDefaultUseCaches(false);
connection = url.openConnection();
}catch(MalformedURLException ex){ System.out.println(ex); }
}catch (IOException.....)
My question is :
Is there another way to solve this problem (other then starting the connection every time)?
Thanks in advance,
Ilana
<<Less