Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Does JSP support inheritance?

 
Manas Ahlaad
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

Does JSP support inhertience , if it does how ?
manas
 
Bill Siggelkow
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you be more specific? Do you mean with custom tags. Remember that a JSP is just an inside-out servlet. Where you can use inheritance (as well as interface implementation) is in the JavaBeans that you use in your JSP pages.
 
Manas Ahlaad
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
i meant to ask is there any provision for one JSP (not the genarated servlet) to inherit form other JSP(even at runtime)
manas
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not that I am aware of. The servlet generated rom a JSP page can extend another class though.
------------------
Bosun
SCJP for the Java� 2 Platform
 
Ashik Uzzaman
Ranch Hand
Posts: 2373
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bosun :

The servlet generated rom a JSP page can extend another class though.

Bosun, can u give n example that u referred I m a newbie in JSP and ...
------------------
Muhammad Ashikuzzaman (Fahim)
Sun Certified Programmer for the Java� 2 Platform
--When you learn something, learn it by heart!
 
Jeff Taylor
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ashik: You have to know that JSPs are based on the Java Servlet techonology. Servlets allow you to do server side programming and to interact with client requests. After the servlet technology was published it wasn't accepted and adopted very well, since servlet programming requires a full understanding of the java programming language. Because of that Sun thought out something named JSP - Java Server Pages, which allow you to create server side java scripts by simply adding some code snippets into plain html and by naming your file something.jsp.
This is what happens behind the scenes: When you request a jsp page, the webserver compiles the jsp page into a servlet and the servlet (a java class) answers the request of the client. (Of course the jsp page is only converted and compiled once when you place it on the server or when you change your jsp.)
I hope you can understand my answer (and i didn't confuse you more than i helped you).
/JT
 
Jeff Taylor
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way... you can't derive from jsp pages. The usage of other classes or packages inside a jsp is of course possible, but inheritance is not.
Perhaps the following goes a bit too far (so please simply ignore if you don't understand).
When you create medium to large sized webpages you will want to apply some tactics (also known as design patterns) when doing servlet/jsp programming. A very common approach is to use the MVC paradigm. This MVC or model view controller clearly separates the single components of web-programming: some parts are responsible for handling the logic and some others are responsible for rendering the view and presenting the stuff to the client. So after all you will want to employ servlets for handling your logic and jsp simply for displaying your information to the user. For this reason a large bunch of java code (or even inheritance) inside a jsp page is unacceptable.
I hope someone finds this information useful.
/JT
[This message has been edited by Jeff Taylor (edited December 08, 2001).]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!