Hi I am write a small client/server web app to understand more about
httpclient/cookie/and httpsession.
On the httpclient side, I use a get method to keep calling a servlet on server.
<clientcode>
HttpClient client = new HttpClient();
GetMethod method = new GetMethod(url);
while ( !done ) {
client.executeMethod(method);
if (method.getStatusCode() == HttpStatus.SC_OK) {
method.getResponseBody();
method.releaseConnection();
} else {
System.out.println("Unexpected failure: " +
method.getStatusLine().toString());
done = true;
}
method.recycle();
method.setPath(url);
sleep(sometime)
}
</clientcode>
on the server side, the doGet() method use this
<servercode>
public void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
request.getSession();
}
</servercode>
The first loop, the client is happy. I found a cookie in the response.
After that it throws the following warning message in my lo4j
<warning-snippet>
06:22:37,843 - WARN org.apache.commons.httpclient.HttpMethodBase - Cookie reject
ed: "$Version=0; JSESSIONID=6D150D24B3D022F9AB835EF4E0AFEC5E; $Path=/webtest". I
llegal path attribute "/webtest". Path of origin: "http://localhost:8080/webtest
/webgenservlet"
</waring-snippet>
On server side, new session is created for each request
Questions are:
Why server keeps creating new session instead of reuse the old one?
What does it mean regarding the Warning.
Advices are greately appreciated.
Happy Coding
-Dan