Please tell me whether the above code is valid? Or will it call the intend page?
Above code is perfectly valid and it will forward the request to included_page.html. request dispatcher is to dispath the current request to any other resource,which you can access from a direct request from your browser,static or dymanic does not matter.
SCJP 91%, TOFAG 9 certified 89%
Joined: Dec 04, 2004
In case of JSP file you are writing lot of html code into the JSP that generate contents to the outputstream. Try only following code.
In your JSP. It will run without error. Try your original code using forward it should run.
But I think in case of include this problem is due to the app server select PrintWriter for writing the html in JSP and the dispatcher is using the outputstream. Both can be used at same time.
In case of forward , If there is enough buffer in output and the response is not commited, the contents will be flushed and request is forwarded to new resource.
I thought you can't include binary content in a forward/include fashion if you don't set the contentType before as corresponding and use getOutputStream. By default contentType is "text/html".. Now i remember a HFSJ question on that, though i don't have the book now and can't remember the chapter.