Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can extends JSP from certain basic class ?

 
Alex Qiu
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there , I now somehow want to extend Jsp from certain basic class .
Then all Jsps can inherit some general function .
Can we do that ?
How ?
 
michelle Wang
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
err.........I only know JSP can include other pages, because it's a "page", not a java class..haha...
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jsp page can extends another class, you can use extends attribute in page directive like that ..
 
Pratibha Malhotra
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Technically speaking, your jsp can no doubt extend another class using extend attribute.

But container generated servlet internally extends a containers pecific class which does the servlet-conatiner mamangement. Now if your jsp extends a class, you can no longer reap fruits of this container specific class. And thus you will have to write class/code for the work this container specific classes generally do.


Writing the class/code is slightly trickier . This class will have to do two things:
1) extend javax.servlet.HttpServlet so that it is an HttpServlet, and
2) implement HttpJspPage so that it is also a JSP servlet.

Hope this helps.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic