This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

can we implement interface to Jsp ?  RSS feed

 
vinoth sathiyamoorthy
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
iam a beginner of jsp.can we use interface in jsp file...?
thanks
 
Jair Rillo Junior
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interfaces are implemented by classes. Hence, in JSP we cannot implement them, but we CAN use them.

For instance: you wanna use the java.util.List interface, you can use it in JSP

<%
java.util.List list = new java.util.ArrayList();
//do anything
%>
 
vinoth sathiyamoorthy
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thaks for your valuable help.
[ UD: Unrelated question removed. Please continue that topic in the other thread you posted, where you have an answer already. ]
thanks.
[ September 30, 2008: Message edited by: Ulf Dittmer ]
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interfaces are implemented by classes. Hence, in JSP we cannot implement them

Not quite. JSPs are generally translated and compiled as servlet classes, so by that measure they could implement interfaces like all other classes.

But the important question is: how would you (as a web app developer) make use of the fact that a JSP implements an interface?

(As a side note, the servlet classes compiled from JSPs generally DO implement an interface. But that's for the internal purposes of the servlet container only, and has nothing to do with the web app.)
 
Aditya Narayan
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@ Ulf Dittmer
Well if I am trying to implement observer pattern of java in servlet jsp, I would really look forward to implement the required interface. This is a practical scenario I am currently working on.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSPs are invoked to render a response to a request, not upon certain Observable events. Thus having them implement Observer makes no sense.

What is the underlying problem you're trying to solve?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!