aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Not able to understand this  HINT from SCWCD HINT. 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 "Not able to understand this  HINT from SCWCD HINT." Watch "Not able to understand this  HINT from SCWCD HINT." New topic
Author

Not able to understand this HINT from SCWCD HINT.

Sagar Shroff
Ranch Hand

Joined: Jun 07, 2011
Posts: 202

" Always remember that the included pages can't do anything to the headers. Be it a servlet or a jsp. "

But why ?? because i did tried one example and it is working fine . i included one jsp which is setting a new header and it is not giving me any problem.
Can someone explain me where i am getting wrong in understanding this statement.

Regards,
Sagar.


OCJP-90%,OCPWCD-95%
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1522
    
  22

From the JSP 2.2 specs:

JSP.5.4 <jsp:include>
An included page cannot change the response status code or set headers. This
precludes invoking methods like setCookie. Attempts to invoke these methods
will be ignored


Regards,
Frits
Sagar Shroff
Ranch Hand

Joined: Jun 07, 2011
Posts: 202

Thanks Frits.

Also one thing i will like to ask you is there anything specified in the specs which says that
"Even if you dont flush the response,you should not write anything in the response or set headers or cookies incase if you gonna do a forward"
Anything like this ? i know that you said earlier that for practical purposes you shouldnt do this but i want to what is specified regarding this matter in the specs,since the exam is all about what specs says

Regards,
Sagar.
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1522
    
  22

Even if you dont flush the response,you should not write anything in the response or set headers or cookies incase if you gonna do a forward"
Anything like this ? i

This is written about it:

SRV.8.4 The Forward Method
The forward method of the RequestDispatcher interface may be called by the
calling servlet only when no output has been committed to the client. If output data
exists in the response buffer that has not been committed, the content must be
cleared before the target servlet's service method is called
. If the response has been
committed, an IllegalStateException must be thrown.
....
Before the forward method of the RequestDispatcher interface returns, the
response content must be sent and committed, and closed by the servlet container.

the phrase "the content must be cleared ..." is what the container should do. Everything that was written to the response (before the forward) is therefore lost.

Regards,
Frits
Sagar Shroff
Ranch Hand

Joined: Jun 07, 2011
Posts: 202

Thank You Frits !

Regards,
Sagar

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Not able to understand this HINT from SCWCD HINT.
 
Similar Threads
<jsp:include> not displaying included file
How to add a parameter for the result within an interceptor?
languages proplem with IE
JSP changes does not reflect
How to set "commentList" attribute in HFSJ p. 441 example?