Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning forum!
  • 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:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

SCWCD - Charles Lyons

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am reading this for SCWCD 1.5. To say the truth, I am not really excited about the book, grammatical errors, and I do not really understand the English language exposed throughout the book, Amazon shows 6 reviews (all 5 stars), I know I should have not bought it, but... the problem is this now, I just read this question as chapter review question:

Which abstract class or interface must be extended or implemented to provide an HTTP servlet ?

A) javax.servlet.Servlet (interface)
B) javax.servlet.GenericServlet (interface)
C) javax.servlet.GenericServlet (abstract class)
D) javax.servlet.http.HttpServlet (abstract class)
E) javax.servlet.http.GenericHttpServlet (abstract class)

I thought the answer should be D only (since HTTP was mentioned in the question), but I was surprised that the correct answer is provided to be A.

Here's the author explanation:

Only Servlet must be ever iimplemented - the other are just convenience classes. The appropriate classes to use are C if you want a protocol independent servlet, or D for an HTTP specific servlet.



what do you guys think ?!
 
Sheriff
Posts: 9674
42
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aj, since the question is about SCWCD, I'm moving it to the SCWCD forum...
 
Aj Deschanel
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ankit Garg wrote:Aj, since the question is about SCWCD, I'm moving it to the SCWCD forum...


Thanks Ankit.
 
Ankit Garg
Sheriff
Posts: 9674
42
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As the question stands to me, I also think that the answer should be D, because the question specifically mentions HTTP servlet.

Edit: On a second thought, if we implement Servlet interface to create a servlet, we can serve HTTP requests. The words "provide an Http Servlet" in the question makes it a little confusing. If the question had said, "Which abstract class or interface must be extended or implemented to serve HTTP requests", then A would've been correct as a servlet that implements the Servlet interface can serve HTTP requests...
 
Ranch Hand
Posts: 462
Scala jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On the subject of this book, personally I find it much easier to read and underdstand than the Head First book which does my swede in. I suppose it depends on how you like to learn.
 
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ankit Garg wrote:As the question stands to me, I also think that the answer should be D, because the question specifically mentions HTTP servlet.

Edit: On a second thought, if we implement Servlet interface to create a servlet, we can serve HTTP requests. The words "provide an Http Servlet" in the question makes it a little confusing. If the question had said, "Which abstract class or interface must be extended or implemented to serve HTTP requests", then A would've been correct as a servlet that implements the Servlet interface can serve HTTP requests...



So the answer is still correct? Its just a matter of correct/appropriate wordings?
 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One such Question is :

Which of the following classes should a JSP page's servlet class must extend?

a) javax.servlet.jsp.JspPage
b) javax.servlet.jsp.HttpJspPage
......
..) Non of these


Ans is: None of these
The explanation is:


The JSP page need not extend any class. It must, however, implement the Servlet interface [since all jsp pages are ultimately converted into a servlet]

This is the hierarcy of the interfaces:

javax.servlet.Servlet <- javax.servlet.jsp.JspPage <- javax.servlet.jsp.HttpJspPage

Now, the base class of the JSP page, which is provided by the servlet container vendor, implements the javax.servlet.jsp.HttpJspPage interface. If you do not provide the 'extends' attribute of page directive, then this is the class that your jsp page's servlet extends from.




I agree on answer A in Aj's question, because you can build a HTTP servlet class from scratch while implementing the Servlet interface is always mandatory.

Similar is the case with convenience classes SimpleTagSupport, TagSupport and BodyTagSupport used to write custom tags. You can just ignore them at your will.
 
I wasn't selected to go to mars. This tiny ad got in ahead of me:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic