• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Not able to understand this HINT from SCWCD HINT.

 
Ranch Hand
Posts: 211
Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
" 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.
 
Creator of Enthuware JWS+ V6
Posts: 3412
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 211
Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 3412
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 211
Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank You Frits !

Regards,
Sagar

 
This parrot is no more. It has ceased to be. Now it's a tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic