Its not that they "didn't think of it" its that they "don't want you to do it".
Didn't someone on this forum once say something like "You can bake a cake by setting your house on fire, but there's probably a better way". The same goes with your question. If you want to put tons of application logic in JSPs, such as requiring they each implement a method, then you shouldn't be using JSPs in the first place.
I almost *never* put any functions in JSPs, I put them in shared libraries that multiple JSPs can use. I think the only I will even break this is if I am writing text processing code (to convert input/output) and I know for sure it will only be called by one page (oh, and I'm being really lazy)... but even then its still better to put it in the library. [ December 15, 2005: Message edited by: Scott Selikoff ]
Originally posted by Kartik Patel: I want all my JSPs to implemet this interface so each and every JSP will have that methods.....
You do realize that implementing an interface doesn't (by itself) give you access to methods from the interface you're implementing, don't you? It's a contract, not an inheritance mechanism. You would still need to code those methods yourself.
If you're not sure what this means, you might want to do some more reading on interfaces.
There really is no need for me to jump into this as the question has already been answered for anyone who is bothering to read the replies. An interface on a JSP would be absolutely useless since there is no way that the JSP class could subsequently be referenced using the interface. "Mammaries on a bull" comes to mind. You might as well ask why they didn't design your car with a shaving mirror in the engine compartment. If you can't use it, why design it?
The fundamental question is: how are you going to call those methods?
If you are calling them from within the JSP, then it doesn't matter if the JSP implements the interface or not, since you still have to write the methods So it doesn't matter if it's an interfact or not, because you are calling the methods from within the same class.
If you are trying to call the methods another way, then we'd need to see your architecture, as there's something amiss.
Theoretical arguments as to the fact that JSPs should be allowed to implement interfaces just becuase that keeps the language pure won't cut it, I'm afraid. There are other theoretical arguments that state that they shouldn't (MVC design pattern, for one)
Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
It's always advisable not to add Java code in JSPs.
1. When you extend any class, your JSP inherits the data members and methods from the base class. You can use those members in your JSP.
2. When implement any interface, it is required to write method body for all the operations written in interface contract. And if you do so, then you will have to write/add Java code in your JSP to implement the method body (which is unexpected anyway).
Hence, it's not allowed to implement any interface in JSPs, to prove it's design.