On Thu, 2005-03-17 at 14:56 -0800, Stone, Robert wrote:

Hi Robert,

<snip>

> Problem is that once I do httpClient.executeMethod(postMethod) I never
> get response back and program hangs until the session timeout. That, I
> understand is due to the fact that instead of replying to POST request,
> SM agent does it thing and redirects to the original targeted page.
> 

That would be quite peculiar if that was the case


> So what I need is to execute POST method end exit without waiting for
> the response to come. Is it possible and if yes can someone tell me how
> to do it?

HttpMethod#abort should do the trick. You'll probably have to call it
from a separate thread, as executeMethod will certainly block the main
execution thread.

Hope this helps

Oleg

> 
>  
> 
> Here's method that will never pass executeMethod line
> 
>  
> 
>      * @param command
> 
>      * @param errors
> 
>      */
> 
>     public void processLogin(HttpServletRequest request,
> 
>             HttpServletResponse response, Object command, BindException
> errors) {
> 
>         HttpClientParams params = client.getParams();
> 
>         params.setParameter(HttpClientParams.ALLOW_CIRCULAR_REDIRECTS,
> 
>                 new Boolean(true));
> 
>         params.setParameter(HttpClientParams.CONNECTION_MANAGER_TIMEOUT,
> 
>                 new Long(3000));
> 
>         params.setParameter(HttpClientParams.REJECT_RELATIVE_REDIRECT,
> 
>                 new Boolean(false));
> 
>         client.setParams(params);
> 
>         UserData userData = (UserData) command;
> 
>         PostMethod post = new PostMethod(smPath);
> 
>         post.addParameter("SMAUTHREASON", "0");
> 
>         // getting right back at ya
> 
>         post
> 
>                 .addParameter("TARGET", "$SM$"
> 
>                         + request.getRequestURL().toString());
> 
>         post.addParameter("USER", userData.getUserName());
> 
>         post.addParameter("PASSWORD", userData.getUserPassword());
> 
>         try {
> 
>             if (logger.isInfoEnabled())
> 
>                 logger.info("Making POST request to " + smPath);
> 
>             client.executeMethod(post);
> 
>             post.releaseConnection();
> 
>             if (logger.isInfoEnabled())
> 
>                 logger.info("Back from executing post");
> 
>             if (post.getStatusCode() == HttpStatus.SC_OK) {
> 
>                 List headers = Arrays.asList(post.getResponseHeaders());
> 
>                 for (Iterator i = headers.iterator(); i.hasNext();) {
> 
>                     processResponseHeaders(errors, i);
> 
>                 }
> 
>                 if (logger.isInfoEnabled())
> 
>                     if (!errors.hasErrors())
> 
>                         logger.info("Successful login for user "
> 
>                                 + userData.getUserName());
> 
>             } else {
> 
>                 errors.rejectValue("userName", "errors.logging.failed",
> 
>                         new String[] { post.getStatusText() }, post
> 
>                                 .getStatusText());
> 
>             }
> 
>         } catch (Exception e) {
> 
>             logger.error(e);
> 
>             errors.rejectValue("userName", "errors.logging.final",
> 
>                     new String[] { e.getMessage() }, e.getMessage());
> 
>         }
> 
>     }
> 


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

Reply via email to