Can one JSP or Servlet extend another Servlet or JSP

Showing Answers 1 - 16 of 16 Answers

praveen kumar IBM

  • Sep 7th, 2006
 

 

We can extent one servlet to another like normal servlets extends HttpServlet.  we can extend one jsp to another jsp like we have page directive in that we have attribute "extends".

 

  Was this answer useful?  Yes

reena

  • Feb 26th, 2007
 



A Servlet cannot extend another servlet as it already extends the HttpServlet and java does not support multiple inheritance.

  Was this answer useful?  Yes

saimakanwal

  • May 17th, 2010
 

A class can extend a Servlet and become a Servlet like this:

class A extends httpservlet and class B extends A

Here B is a Servlet because this class B is extending a class A which is a Servlet, but a Servlet B cannot extend Servlet A such that Class A extends httpservlet and class B extends A , httpservlet, this is impossible because multiple inheritance is not allowed in Java.

Now for JSP, a JSP can extend another class or servlet because in case of JSP, the generated servlet IMPLEMENTS javax.servlet.jsp.HttpJspPage interface. (does not extend so there is no multiple inheritance) and we can achieve this with the help of page directive's extends attribute.

  Was this answer useful?  Yes

Student

  • Apr 29th, 2018
 

Servlet extends HttpServlet
Servlet1 extends only Servlet
Now, as Servlet1 extends Servlet class (i.e. a Servlet) . Servlet1 also becomes a servlet.
It is multilevel this way but Servlet1 has to override methods in order to behave differently.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions