Howdy ranchers,
I am reading the OCEJWCD Study companion chapter 6 and I came across the topic which talks about additional request attributes that are set by the container when you call forward/include method on a RequestDispatcher instance.
The book says that the various paths in request object are updated by the container on calling forward/include to reflect the path of the resource included or forwarded. It also states that the path of the original
servlet making this call is stored in the request as special attributes. However, I found that this doesnt agree with the execution results. I am using
Tomcat 7.0.42
In case I call forward, I see that the paths in the request object passed to the forwarded resource reflects that of the resource itself and the attributes are set to reflect the path of the original servlet that made the call. However, in case of include, I noticed that when I access the path information from the included resource, the path still reflects the original servlet that made the call and not the included resource. However, the additional request attributes were holding the included resource path information. So basically, here the information got swapped between the request object paths and the attributes.
Which one is correct? Logically, the execution results seem correct to me. I check the book's errata but couldnt find anything related to this.
Did anybody try this and found similar results?
Another discrepancy I found is as follows:
As per the book, ServletException can be either temporary or permanent but UnavailableException is always permanent. However the API has two constructors for UnavailableException one for temporary and one for permanent whereas the ServletException doesn't have any constructor for indicating that this is a temporary. Which one is correct?
Lastly, whats the difference between HttpServletResponse.flushBuffer() and PrintWriter.flush() (latter is obtained from the former)
Your expert answers are warmly appreciated.
Regards
Dinkar