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

Implementing an interface in JSP- Possible?

Desai Sandeep
Ranch Hand

Joined: Apr 02, 2001
Posts: 1157
Hi,
I am aware of the extends attribute in the page directive.Am wondering, if a implements attribute also exists?
Thanks in advance.
Regards

------------------
Sandeep Desai
vgdesai@bom3.vsnl.net.in

  1. Sun Certified Java Programmer Scored 93 per cent
  2. Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java Scored 56 out of 59
  3. IBM Enterprise Connectivity with J2EE Scored 72 per cent
  4. Enterprise Development on the Oracle Internet Platform Scored 44 out of 56
Phil Hanna
Ranch Hand

Joined: Apr 05, 2001
Posts: 118
No, there is no mechanism for doing this, other than writing your own superclass that implements the interface, and then having your JSP specify that superclass with <%@ page extends="mysuperclass" %>
You can, however, define an inner class that implements the interface, and contain an instance of the inner class:

------------------
Phil Hanna
Sun Certified Programmer for the Java 2 Platform
Author of :
JSP: The Complete Reference
Instant Java Servlets
Website: http://www.philhanna.com


Phil Hanna<BR>Sun Certified Programmer for the Java 2 Platform<BR>Author of :<BR><A HREF="http://www.amazon.com/exec/obidos/ASIN/0072127686/electricporkchop/107-3548162-1137317" TARGET=_blank rel="nofollow">JSP: The Complete Reference</A><BR><A HREF="http://www.amazon.com/exec/obidos/ASIN/0072124253/electricporkchop/107-3548162-1137317" TARGET=_blank rel="nofollow">Instant Java Servlets</A>
Desai Sandeep
Ranch Hand

Joined: Apr 02, 2001
Posts: 1157
Hi Phil,
Thanks for the response.
I also thought that implements attribute is not possible in JSP.However Java Servlet Programming,Jason Hunter with William Crawford disagrees with us at Page 40-41, where he introduces a directive tag called implements
Am quoting the information in this post :

Specifies the list of interfaces the servlet should implement.Multiple interfaces can be given by comma-seperated list or given through multiple import directives.For example:

The default behaviour is not to implement anything

I am trying this directive now, and would keep you informed.
Thanks once again.
Regards,

------------------
Sandeep Desai
vgdesai@bom3.vsnl.net.in

  1. Sun Certified Java Programmer Scored 93 per cent
  2. Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java Scored 56 out of 59
  3. IBM Enterprise Connectivity with J2EE Scored 72 per cent
  4. Enterprise Development on the Oracle Internet Platform Scored 44 out of 56
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Originally posted by Desai Sandeep:
I also thought that implements attribute is not possible in JSP.However Java Servlet Programming,Jason Hunter with William Crawford disagrees with us at Page 40-41, where he introduces a directive tag called implements

It may be/have been there in some versions or implementations of JSP, but it's certainly not part of JSP 1.1. Read 2.7.1.1 in the spec.
- Peter
Desai Sandeep
Ranch Hand

Joined: Apr 02, 2001
Posts: 1157
Hi Peter,
Found out that it was a part of JSP 0.91.But why have they removed the implements directive then?
Thanks in advance,

------------------
Sandeep Desai
vgdesai@bom3.vsnl.net.in

  1. Sun Certified Java Programmer Scored 93 per cent
  2. Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java Scored 56 out of 59
  3. IBM Enterprise Connectivity with J2EE Scored 72 per cent
  4. Enterprise Development on the Oracle Internet Platform Scored 44 out of 56
Dustin Marx
Ranch Hand

Joined: Mar 06, 2001
Posts: 40
I cannot think of a good reason for having "implements" functionality in a JSP. Do you have a particular usage in mind?
Desai Sandeep
Ranch Hand

Joined: Apr 02, 2001
Posts: 1157
Well, yes, otherwise the only workaround is what Phil has suggested

[...] other than writing your own superclass that implements the interface, and then having your JSP specify that superclass with <%@ page extends="mysuperclass" %>

Why should JSP (which is based on Java!!) require this workaround.Wouldn't implements directive be better!!
I still cannot understand why they removed this directive.Obviously,there must be a good reason to do so..we need to find out!!
Regards,
Sandeep Desai
vgdesai@bom3.vsnl.net.in

  1. Sun Certified Java Programmer Scored 93 per cent
  2. Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java Scored 56 out of 59
  3. IBM Enterprise Connectivity with J2EE Scored 72 per cent
  4. Enterprise Development on the Oracle Internet Platform Scored 44 out of 56

  5. [This message has been edited by Desai Sandeep (edited April 26, 2001).]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Implementing an interface in JSP- Possible?