Signature of all the doXxx() methods
posted 19 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
The Servlet specification p.231 says that the method signature is
protected void doGet(HttpServletRequest req,HttpServletResponse resp) throws ServletException, IOException. Yet in the HFSJbook all the examples show public void doGet..... So is it public or protected?
What is the correct signature? What will be excepted as right in the exam?
protected void doGet(HttpServletRequest req,HttpServletResponse resp) throws ServletException, IOException. Yet in the HFSJbook all the examples show public void doGet..... So is it public or protected?
What is the correct signature? What will be excepted as right in the exam?
SCJP 1.4<br />SCWCD 1.4
posted 19 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
We create our own servlet by extending the HttpServlet and overriding the doGet() or doPost(). When it comes to overriding a method defined in the parent class, the subclass can either have the same method signature defined in the parent class or the access specifer can be in widening manner. i.e., default => protected => coderanch.
Hope this helps. Refer Overriding for further details
Hope this helps. Refer Overriding for further details
Only those who will risk going too far can possibly find out how far one can go !!!
Dirk Lombard
Greenhorn
Posts: 18
posted 19 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Thanks for pointing out the Overriding rule.
So if you have a question like this in the exam:
Which of the following is the correct full signature of a method of HttpServlet that is called for an HTTP GET request?
Must it then be protected?
So if you have a question like this in the exam:
Which of the following is the correct full signature of a method of HttpServlet that is called for an HTTP GET request?
Must it then be protected?
SCJP 1.4<br />SCWCD 1.4
posted 19 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
HttpServlet abstarct class has protected void doGet(HttpServletRequest req,HttpServletResponse resp) which will be called for an HTTP GET request .
In case you extend this class then the modifier of doGet can be both public and protected since the questions asks about the signature in HttpServlet then it should be protected
In case you extend this class then the modifier of doGet can be both public and protected since the questions asks about the signature in HttpServlet then it should be protected
scjp 1.4<br />scwcd 1.4
| Stop it! You're embarassing me! And you are embarrassing this tiny ad! The new gardening playing cards kickstarter is now live! https://www.kickstarter.com/projects/paulwheaton/garden-cards |






