This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

can an interface be implemented in jsp  RSS feed

 
Mintoo Jaiswal
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can an interface be implemented in jsp
 
Shrinivas Mujumdar
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Mintoo,
You can't directly implement interface in JSP but surely you can have a indirect implementation by extending user defined class which intern implements(empty impplenmentation will also do) Interface you want.

e.g
public class JSPBaseImpl implements .......,......,ILogin(user defined Interface dot indicates some predefined interfaces this class should implement )

{
//define all methods
}


use page direcive as follows
<%@page extends="JSPBaseImpl" %>

i hope this helps otherwise feel free to revert back.





Shrinivas
 
Kriti Garg
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
can pls specify me why JSp specification impose a restriction behind
implementing Interface.
i mean why cannot we implement Interface in JSP


Thanks
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why would you want to?
Given the nature of a container managed JSP's lifecycle, I can't imagine a good reason to want to implement any other interfaces from one.
A JSP is not something you pass around.

There is the <%@ page extends=.... directive.
You could always implement your own JSP superclass and have it implement whatever you want.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!