File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Doubt in a servlet spec 3.0 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Doubt in a servlet spec 3.0 " Watch "Doubt in a servlet spec 3.0 " New topic
Author

Doubt in a servlet spec 3.0

varun Dosapati
Ranch Hand

Joined: Nov 18, 2010
Posts: 30

Hello

I am preparing for OCPJWCD. I hope this is the right place to ask. I came across some statements while reading the spec which doesn't make sense for me.

"If any of the dispatch methods are called before the container-initiated dispatch that called startAsync has returned to the container, then the call will not take effect until after the container-initiated dispatch has returned to the container. Invocation of the AsyncListener.onComplete(AsyncEvent), AsyncListener.onTimeout(AsyncEvent) and AsyncListener.onError(AsyncEvent) will also be delayed till after the container-initiated dispatch has returned to the container."

I would appreciate if some one explains.

Thanks
Varun
Anirudh Gupta
Ranch Hand

Joined: Dec 08, 2010
Posts: 48

Hi,

Not sure if you have understood it by now, but I agree that the language used is perhaps not the best.
After reading the same passage 4 times I too could not reach a conclusive understanding.

However this is my take, may be we can discuss and reach a better understanding together.

1. A request initiates an AsyncContext
2. The AsyncContext can do the following, without throwing an IllegalStateException
2.i. Dispatch it to a Servlet/JSP which does NOT support AsynContext OR
2.ii. Dispatch it to a Servlet/JSP which supports AsynContext OR
2.iii. Dispatch it to itself(this does not make much sense) followed by
3. The AyncContext calls the complete and the request/response are committed, the Async thread ends etc. etc.

In (2), The HTTP thread, from which AsyncContext thread was initiated, will carry on its processing and will do a
dispatch ie. move the original request and response along (either forward or respond back to the client).
NOW here in lies the rub, All AsyncContext initiated dispatches will wait till the HTTP thread initiated dispatch
has completed it's job and has returned back to the container. The AsyncContext initiated dispatches will follow
the completion of HTTP thread's dispatch.

I have posted a query in the Servlets board "AsyncContext. WebFilter - Glassish4.0". May be you can help me with
that.

Regards,
Anirudh


Regards,
Anirudh
varun Dosapati
Ranch Hand

Joined: Nov 18, 2010
Posts: 30


Hi Anirudh

firstly thanks for taking time to explain me...

NOW here in lies the rub, All AsyncContext initiated dispatches will wait till the HTTP thread initiated dispatch
has completed it's job and has returned back to the container. The AsyncContext initiated dispatches will follow
the completion of HTTP thread's dispatch.


But I am confused with your statement.

I don't know what you mean by HTTP thread initiated request(is that mean Servletrequest ).. Not sure

Also I will try to recreate your issue in my machine and will get back to you....


Thanks
Varun





Anirudh Gupta
Ranch Hand

Joined: Dec 08, 2010
Posts: 48

Hi,

I think you mean this specific sentence.

All AsyncContext initiated dispatches will wait till the HTTP thread initiated dispatch
has completed it's job and has returned back to the container.


I was trying to say, that the request dispatch to another resource(read forward etc) as initiated by the original HTTP
thread will complete and the thread will come back to the service methods before any dispatch from the AsyncContext
thread can happen.

Refer Servlet 3.0 specification, Section 2.3.3.3, AsyncContext from page 15. The code examples after the description of public void dispatch() method.

Mind you I too am exploring this, so not VERY sure.

On the other hand my earlier posted query is now closed.
I was configuring the filter incorrectly. It must be configured with asyncSupported=true if its corresponding servlet is also so configured,
besides other minor things that I had misunderstood.

I have posted another query on Path Elements, may be you can take help me with that.

Regards,
Anirudh.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt in a servlet spec 3.0