• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Not able to understand this HINT from SCWCD HINT.  RSS feed

 
Ranch Hand
Posts: 209
Java Tomcat Server
  • Mark post as helpful
  • send pies
  • 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
Bartender
Posts: 3121
259
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • 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: 209
Java Tomcat Server
  • Mark post as helpful
  • send pies
  • 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
Bartender
Posts: 3121
259
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • 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: 209
Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You Frits !

Regards,
Sagar

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!