Page 1 of 1

About Question enthuware.jwpv6.2.747 :

Posted: Thu Jan 14, 2016 7:09 pm
by grendel777@o2.pl
What if different protocol request (not HTTP) is made to url mapped to HttpServlet?

Will option "For any and every request, at least 1 of its methods will be called." be incorrect?

Re: About Question enthuware.jwpv6.2.747 :

Posted: Thu Jan 14, 2016 9:00 pm
by admin
Unless specified in the question, or unless the question is clearly about the protocols, you have to consider HTTP only.

But to answer your question, I am not sure how you can map a protocol to a servlet. A protocol is implemented by the web server, which interprets the incoming request and invokes appropriate handler. For example, if an HTTP request goes to Tomcat server, it will interpret the request and forward it to appropriate servlet. If you send a non-http request to Tomcat, it will not understand the request and there is no question of the request reaching the servlet.

Re: About Question enthuware.jwpv6.2.747 :

Posted: Sat Jan 16, 2016 8:02 am
by grendel777@o2.pl
For sure I agree it would be a problem with any server available.
Yet, regarding spec itself, GenericServlet was intended to be protocol independent.

Re: About Question enthuware.jwpv6.2.747 :

Posted: Sat Jan 16, 2016 9:00 am
by admin
GenericServlet, yes, it can be used for any protocol. But HttpServlet, No. HttpServlet is meant for HTTP only.

Re: About Question enthuware.jwpv6.2.747 :

Posted: Sun Apr 24, 2016 8:03 pm
by himaiMinh
Hi,
the explanation says when the first request is made to a servlet, the init() method is called.
By according to Chapter 2.3.2 of Serlvet 3.0 specification, init() method is called before the servlet handles any request.
So, I think regardless there is a first request or not, the init() method is always called after the serlvet has been instantiated.

Re: About Question enthuware.jwpv6.2.747 :

Posted: Sun Apr 24, 2016 8:49 pm
by admin
But a container may not even initialize a servlet if there is no request. You can only state for certain that it will be called before the first request is processed by the servlet.

This question clearly specifies, "Assuming that it is not preloaded or preinitialized,....", therefore the explanation is correct.

HTH,
Paul.