RE: Seeking help using Cookie and Session

2003-09-17 Thread Kalnichevski, Oleg
Eric,

I think we should keep 'recycle' for another while. Once we have HttpMethod split into 
HttpRequest/HttpResponse pair of interfaces, a request object may be reused as many 
times are needed without having to resort to recycling tricks of any sort.

Oleg


-Original Message-
From: Eric Johnson [mailto:[EMAIL PROTECTED]
Sent: Wednesday, September 17, 2003 5:10 PM
To: Commons HttpClient Project
Subject: Re: Seeking help using Cookie and Session


A follow-up question, directed towards the rest of the group

Shouldn't "recycle" be deprecated for the 2.1 release?  Seems like we've 
discussed it before, and all it gives us is a chance for uses like the 
following, where my first reaction was that maybe the "recycle" call 
didn't work properly.  I don't think it adds much for performance, and 
it makes the API more confusing, I think.

To Dan,

You might want to structure your call slightly differently, as well:

try {
  client.executeMethod(method);
  // do what you want here...
}
finally {
  // guarantee that you always release the connection - critical if you 
switch
  // to MultiThreadedHttpConnectionManager().
  method.releaseConnection();
}

-Eric.


Dan Tran wrote:

>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.
>
>
>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)
>
>   }
>
>
>
>on the server side, the doGet() method use this
>
>
>  public void doGet(HttpServletRequest request, HttpServletResponse response) throws 
> ServletException, IOException {
>request.getSession();
>  }
>
>
>
>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
>
>
>  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"
>
>
>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
>
>  
>



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Seeking help using Cookie and Session

2003-09-17 Thread Dan Tran
Dear Eric and Oleg,

I put in the code to handle brower compatibility cookie.
Now it works. Thank you Thank you.

Eric, thanks for the advice. I took out recycle call
and handle releaseConnection correctly.

Thanks for every thing

-Dan

- Original Message - 
From: "Eric Johnson" <[EMAIL PROTECTED]>
To: "Commons HttpClient Project" <[EMAIL PROTECTED]>
Sent: Wednesday, September 17, 2003 8:09 AM
Subject: Re: Seeking help using Cookie and Session


> A follow-up question, directed towards the rest of the group
>
> Shouldn't "recycle" be deprecated for the 2.1 release?  Seems like we've
> discussed it before, and all it gives us is a chance for uses like the
> following, where my first reaction was that maybe the "recycle" call
> didn't work properly.  I don't think it adds much for performance, and
> it makes the API more confusing, I think.
>
> To Dan,
>
> You might want to structure your call slightly differently, as well:
>
> try {
>   client.executeMethod(method);
>   // do what you want here...
> }
> finally {
>   // guarantee that you always release the connection - critical if you
> switch
>   // to MultiThreadedHttpConnectionManager().
>   method.releaseConnection();
> }
>
> -Eric.
>
>
> Dan Tran wrote:
>
> >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.
> >
> >
> >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)
> >
> >   }
> >
> >
> >
> >on the server side, the doGet() method use this
> >
> >
> >  public void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
> >request.getSession();
> >  }
> >
> >
> >
> >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
> >
> >
> >  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"
> >
> >
> >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
> >
> >
> >
>
>
>
> -
> To unsubscribe, e-mail:
[EMAIL PROTECTED]
> For additional commands, e-mail:
[EMAIL PROTECTED]
>
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Seeking help using Cookie and Session

2003-09-17 Thread Eric Johnson
A follow-up question, directed towards the rest of the group

Shouldn't "recycle" be deprecated for the 2.1 release?  Seems like we've 
discussed it before, and all it gives us is a chance for uses like the 
following, where my first reaction was that maybe the "recycle" call 
didn't work properly.  I don't think it adds much for performance, and 
it makes the API more confusing, I think.

To Dan,

You might want to structure your call slightly differently, as well:

try {
 client.executeMethod(method);
 // do what you want here...
}
finally {
 // guarantee that you always release the connection - critical if you 
switch
 // to MultiThreadedHttpConnectionManager().
 method.releaseConnection();
}

-Eric.

Dan Tran wrote:

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.


   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)

  }

on the server side, the doGet() method use this


 public void doGet(HttpServletRequest request, HttpServletResponse response) throws 
ServletException, IOException {
   request.getSession();
 }

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


 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"

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

 



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


RE: Seeking help using Cookie and Session

2003-09-17 Thread Kalnichevski, Oleg
Dan,
Before I could give you a more precise answer, I would need some additional input from 
you. 

- What kind of cookie policy have you been using? Have you tried using browser 
compatibility policy?
  If unsure, you may want to consult our cookie guide:
  

- What kind of servlet engine are you running on the server?

- Could you produce the wire log of the session in question. 
  Take a look at the logging guide for the instructions on how to activate wire 
logging:
  

Cheers

Oleg

-Original Message-
From: Dan Tran [mailto:[EMAIL PROTECTED]
Sent: Wednesday, September 17, 2003 4:44 PM
To: Commons HttpClient Project
Subject: Seeking help using Cookie and Session


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.


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)

   }



on the server side, the doGet() method use this


  public void doGet(HttpServletRequest request, HttpServletResponse response) throws 
ServletException, IOException {
request.getSession();
  }



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


  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"


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

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]