aspose file tools*
The moose likes JSP and the fly likes Implementing Interface in JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Implementing Interface in JSP" Watch "Implementing Interface in JSP" New topic
Author

Implementing Interface in JSP

Dany Samuel
Greenhorn

Joined: Aug 07, 2006
Posts: 3
Hi

How to implement Interface in a JSP Page.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Don't?

An interface would introduce new behaviour, but the intended behaviour for a JSP is to be a JSP.
Dany Samuel
Greenhorn

Joined: Aug 07, 2006
Posts: 3
Ok

If I have my own set of methods which will be common for wide range of JSP pages.

So I am planning to write an interface with these method declerations which can be implemented wherever I need.

So How to accomplish this.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

That behaviour does not belong in the JSP itself.

Preferably you would look at implementing them as tags rather than making method calls, but you could also consider just moving the functionality out to a separate helper class.
Naresh Shaan
Greenhorn

Joined: Mar 18, 2006
Posts: 22
we all know that JSP's are trasnlated to a servlet. servlet is just like any other class.

So is there way where i can make a jsp implement a interface???


"The greatest pleasure in life is doing what people say you cannot do." - Walter Bagehot
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

No.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Naresh Shaan
Greenhorn

Joined: Mar 18, 2006
Posts: 22
Originally posted by Ben Souther:
No.




Can i know Why??
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

As a developer, you never pass instances of JSPs around.
What would the point of implementing an interface be?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61206
    
  66

Re-iterating the opinion of the other experienced developers: this is not an appropirate way to extend the capabilities of a JSP.

Not only is it pointless; interfaces are for allowing external code to deal with an object instance in a specific manner, and there is no external access to a JSP. But there are many supported means to extend JSP behavior: custom actions, EL functions and so on.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Dany Samuel
Greenhorn

Joined: Aug 07, 2006
Posts: 3
Ok Thanks for all your replies

I was just curious why in JSP we can extend a class but why not implement and interface.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61206
    
  66

Now you know.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Implementing Interface in JSP