Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Implementing Interface in JSP

 
Dany Samuel
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

How to implement Interface in a JSP Page.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't?

An interface would introduce new behaviour, but the intended behaviour for a JSP is to be a JSP.
 
Dany Samuel
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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???
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
 
Naresh Shaan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ben Souther:
No.




Can i know Why??
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64708
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Dany Samuel
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64708
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now you know.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic