• Post Reply Bookmark Topic Watch Topic
  • New Topic

HF Servlets and JSP 2nd ed, ch 5 Coffee Cram, dubious answers  RSS feed

 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am preparing for the SCWCD 5. In HF Servlets and JSP 2nd ed, ch 5 Coffee Cram, I have a feeling that the answers provided for the following questions may be wrong or at least dubious.
Q2:
Answer given in the book are options A, D and F.

My doubt about option D:
The question never mentions about the ServletContext variable. In the ServletContext API, getInitParameter() method is non static and can not be invoked using the class name. We need something like a getServletContext().getInitParameter(String).

Q15:
Answer given in the book are options A, and C.

My doubt about option C:
If an absolute path is used starting with a slash (/), the path to the resource would be independent of the class whose method creates a RequestDispatcher.

Am I right?
 
Creator of Enthuware JWS+ V6
Saloon Keeper
Posts: 3069
248
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

My doubt about option D:
The question never mentions about the ServletContext variable. In the ServletContext API, getInitParameter() method is non static and can not be invoked using the class name. We need something like a getServletContext().getInitParameter(String).


You are right. The writers only want to show you that the method is on the ServletContext object, but not how it should be called (and from a Servlet it is called like you are writing)

My doubt about option C:
If an absolute path is used starting with a slash (/), the path to the resource would be independent of the class whose method creates a RequestDispatcher.


Correct!

Regards,
Frits
 
a sarkar
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Frits. I hope someone would read this thread and correct these mistakes in the next edition.
 
Ranch Hand
Posts: 611
1
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, it's weird because I hold the 2nd edition of HF book in my hands, and C answer sounds:

Depending on the class whose method creates a RequestDispatcher, the path to the resource to be forwarded to may change.

 
Greenhorn
Posts: 4
Java MySQL Database PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which statements about ServletContext initialization parameters are true? (Choose all that apply.)
A. They should be used for data that changes rarely.

I have doubt here. How A is correct.? since Initialization parameters cannot be changed (no setInitParameters) rarely or frequently.

If it is silly.. sorry.. i am fresher to this topic.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Posts: 3069
248
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have doubt here. How A is correct.? since Initialization parameters cannot be changed (no setInitParameters) rarely or frequently.



As of Servlet 3.0 there is that possibility: ServletContext API
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Frits Walraven wrote:

I have doubt here. How A is correct.? since Initialization parameters cannot be changed (no setInitParameters) rarely or frequently. 



As of Servlet 3.0 there is that possibility: ServletContext API




You are right, but the book Head First Servlets and JSP mentioned that answer even though that book is for java5, servlet 2.4. and since that there was no way to change the init parameters.
 
Curse your sudden but inevitable betrayal! And this tiny ad too!
ScroogeXHTML 7.1 - RTF to HTML5 / XHTML converter
https://coderanch.com/t/690611/ScroogeXHTML-RTF-HTML-XHTML-converter
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!