You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Milt Epstein <me...@uiuc.edu> on 2001/04/01 16:45:35 UTC

Re: getServletNames()?

On Sun, 1 Apr 2001, George Kakarontzas wrote:

> Hi all.
> I have been trying to make this run:
> ====================================
> import javax.servlet.http.*;
> 
> public class Loaded extends HttpServlet {
> 
>   public void doGet(HttpServletRequest req, HttpServletResponse res)
>                                throws ServletException, IOException {
>     res.setContentType("text/plain");
>     PrintWriter out = res.getWriter();
>     ServletContext context = getServletContext();
>     Enumeration names = context.getServletNames();
>     while (names.hasMoreElements()) {
>       String name = (String)names.nextElement();
>       Servlet servlet = context.getServlet(name);
>       out.println("Servlet name: " + name);
>       out.println("Servlet class: " + servlet.getClass().getName());
>       out.println("Servlet info: " + servlet.getServletInfo());
>       out.println();
>     }
>   }
> }
> ========================================
> However the Enumeration returned by context.getServletNames() is empty!
> It is supposed to return the serlvets loaded (including Loaded itself). 
> I know that this method has been deprecated in jdk1.3, which I'm
> using, but it should work anyway.
> Any suggestions?

Why do you think it should work even if it's been deprecated?  This
method was deprecated long ago, in JSDK Spec 2.1, and doesn't do
anything anymore (like it's related method, getServlet()).

Milt Epstein
Research Programmer
Software/Systems Development Group
Computing and Communications Services Office (CCSO)
University of Illinois at Urbana-Champaign (UIUC)
mepstein@uiuc.edu


Beginner question - revised

Posted by Gabe Mahoney <ma...@pacbell.net>.
Hey all, I sent a mail earlier about having trouble with configuring tomcat
to handle extension types other than .jsp. The problem is not exactly as I
thought. I have modified web.xml so that type .rt is now handled by tomcat.
My .rt file is just a jsp page with a different extension. I get the error
below whenever I access a .rt file in my context, whether the .rt file
exists or not! Which seems really weird to me...Thoughts?

Error: 500
Location: /djmalloc/foo.rt
Internal Servlet Error:

java.lang.InstantiationException: malloc.servlet.PageGetter
 at java.lang.Class.newInstance0(Native Method)
 at java.lang.Class.newInstance(Class.java:237)
 at
org.apache.tomcat.core.ServletWrapper.loadServlet(ServletWrapper.java:268)
 at org.apache.tomcat.core.ServletWrapper.init(ServletWrapper.java:289)
 at org.apache.tomcat.core.Handler.service(Handler.java:254)
 at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
 at
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:79
7)
 at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
 at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC
onnectionHandler.java:210)
 at
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
 at
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
 at java.lang.Thread.run(Thread.java:484)




Re: getServletNames()?

Posted by Milt Epstein <me...@uiuc.edu>.
On Sun, 1 Apr 2001, George Kakarontzas wrote:

> Actually it's interesting you mentioned Jason Hunter because I found
> this example in his excellent Java Selvet Programming book
> (p. 339). However it seems that some of the stuff in there it just
> got old although all the examples (if you exclude interservlet
> communication) ran without problems. I think there's a new version
> of this book coming out this month.
[ ... ]

Yes, the first edition of that book (which is a couple of years old),
was written to JSDK 2.0.  Those articles were in some sense
supplements/updates to the book to cover the new servlet specs that
came out in the interim.  And the second edition is in fact already
out (I haven't seen it myself, but that's what I've heard).


> ----- Original Message -----
> From: "Milt Epstein" <me...@uiuc.edu>
> To: <to...@jakarta.apache.org>
> Sent: Sunday, April 01, 2001 7:48 PM
> Subject: Re: getServletNames()?
> 
> 
> > On Sun, 1 Apr 2001, George Kakarontzas wrote:
> >
> > > OK Milt thanks.
> > > I should read the spec before I ask. It clearly says:
> > > "This method was originally defined to return an Enumeration of
> > > all the servlet names known to this context. In this version,
> > > this method always returns an empty Enumeration and remains only
> > > to preserve binary compatibility. This method will be
> > > permanently removed in a future version of the Java"
> > 
> > Oh, yeah, should've thought to suggest just looking at the spec.
> > I get a lot of my info on the spec changes from a couple of
> > articles Jason Hunter (author of O'Reilly's Servlets book) wrote
> > for JavaWorld.  I don't have the exact URLs handy, but one is from
> > December 1998 (the one that covers the changes from 2.0 to 2.1)
> > and one is from October 1999 (from 2.1 to 2.2) -- and that should
> > give you an idea how old this stuff is.
> >
> >
> > > ----- Original Message -----
> > > From: "Milt Epstein" <me...@uiuc.edu>
> > > To: <to...@jakarta.apache.org>
> > > Sent: Sunday, April 01, 2001 5:45 PM
> > > Subject: Re: getServletNames()?
> > >
> > >
> > > > On Sun, 1 Apr 2001, George Kakarontzas wrote:
> > > >
> > > > > Hi all.
> > > > > I have been trying to make this run:
> > > > > ====================================
> > > > > import javax.servlet.http.*;
> > > > >
> > > > > public class Loaded extends HttpServlet {
> > > > >
> > > > >   public void doGet(HttpServletRequest req, HttpServletResponse res)
> > > > >                                throws ServletException, IOException
> {
> > > > >     res.setContentType("text/plain");
> > > > >     PrintWriter out = res.getWriter();
> > > > >     ServletContext context = getServletContext();
> > > > >     Enumeration names = context.getServletNames();
> > > > >     while (names.hasMoreElements()) {
> > > > >       String name = (String)names.nextElement();
> > > > >       Servlet servlet = context.getServlet(name);
> > > > >       out.println("Servlet name: " + name);
> > > > >       out.println("Servlet class: " + servlet.getClass().getName());
> > > > >       out.println("Servlet info: " + servlet.getServletInfo());
> > > > >       out.println();
> > > > >     }
> > > > >   }
> > > > > }
> > > > > ========================================
> > > > > However the Enumeration returned by
> > > > > context.getServletNames() is empty!  It is supposed to
> > > > > return the serlvets loaded (including Loaded itself).  I
> > > > > know that this method has been deprecated in jdk1.3, which
> > > > > I'm using, but it should work anyway.
> > > > > Any suggestions?
> > > > 
> > > > Why do you think it should work even if it's been deprecated?
> > > > This method was deprecated long ago, in JSDK Spec 2.1, and
> > > > doesn't do anything anymore (like it's related method,
> > > > getServlet()).
> > > >
> > >
> >
> 

Milt Epstein
Research Programmer
Software/Systems Development Group
Computing and Communications Services Office (CCSO)
University of Illinois at Urbana-Champaign (UIUC)
mepstein@uiuc.edu


Re: getServletNames()?

Posted by George Kakarontzas <gk...@inf.uth.gr>.
Actually it's interesting you mentioned Jason Hunter because I found this
example in his excellent Java Selvet Programming book (p. 339). However it
seems that some of the stuff in there it just got old although all the
examples (if you exclude interservlet communication) ran without problems. I
think there's a new version of this book coming out this month.

I'll have a look at Java World.

Thanks again.

-George



----- Original Message -----
From: "Milt Epstein" <me...@uiuc.edu>
To: <to...@jakarta.apache.org>
Sent: Sunday, April 01, 2001 7:48 PM
Subject: Re: getServletNames()?


> On Sun, 1 Apr 2001, George Kakarontzas wrote:
>
> > OK Milt thanks.
> > I should read the spec before I ask. It clearly says:
> > "This method was originally defined to return an Enumeration of all the
> > servlet names known to this context. In this version, this method always
> > returns an empty Enumeration and remains only to preserve binary
> > compatibility. This method will be permanently removed in a future
version
> > of the Java"
>
> Oh, yeah, should've thought to suggest just looking at the spec.  I
> get a lot of my info on the spec changes from a couple of articles
> Jason Hunter (author of O'Reilly's Servlets book) wrote for JavaWorld.
> I don't have the exact URLs handy, but one is from December 1998 (the
> one that covers the changes from 2.0 to 2.1) and one is from October
> 1999 (from 2.1 to 2.2) -- and that should give you an idea how old
> this stuff is.
>
>
> > ----- Original Message -----
> > From: "Milt Epstein" <me...@uiuc.edu>
> > To: <to...@jakarta.apache.org>
> > Sent: Sunday, April 01, 2001 5:45 PM
> > Subject: Re: getServletNames()?
> >
> >
> > > On Sun, 1 Apr 2001, George Kakarontzas wrote:
> > >
> > > > Hi all.
> > > > I have been trying to make this run:
> > > > ====================================
> > > > import javax.servlet.http.*;
> > > >
> > > > public class Loaded extends HttpServlet {
> > > >
> > > >   public void doGet(HttpServletRequest req, HttpServletResponse res)
> > > >                                throws ServletException, IOException
{
> > > >     res.setContentType("text/plain");
> > > >     PrintWriter out = res.getWriter();
> > > >     ServletContext context = getServletContext();
> > > >     Enumeration names = context.getServletNames();
> > > >     while (names.hasMoreElements()) {
> > > >       String name = (String)names.nextElement();
> > > >       Servlet servlet = context.getServlet(name);
> > > >       out.println("Servlet name: " + name);
> > > >       out.println("Servlet class: " + servlet.getClass().getName());
> > > >       out.println("Servlet info: " + servlet.getServletInfo());
> > > >       out.println();
> > > >     }
> > > >   }
> > > > }
> > > > ========================================
> > > > However the Enumeration returned by context.getServletNames() is
empty!
> > > > It is supposed to return the serlvets loaded (including Loaded
itself).
> > > > I know that this method has been deprecated in jdk1.3, which I'm
> > > > using, but it should work anyway.
> > > > Any suggestions?
> > >
> > > Why do you think it should work even if it's been deprecated?  This
> > > method was deprecated long ago, in JSDK Spec 2.1, and doesn't do
> > > anything anymore (like it's related method, getServlet()).
> > >
> >
>
> Milt Epstein
> Research Programmer
> Software/Systems Development Group
> Computing and Communications Services Office (CCSO)
> University of Illinois at Urbana-Champaign (UIUC)
> mepstein@uiuc.edu
>


Re: getServletNames()?

Posted by Milt Epstein <me...@uiuc.edu>.
On Sun, 1 Apr 2001, George Kakarontzas wrote:

> OK Milt thanks.
> I should read the spec before I ask. It clearly says:
> "This method was originally defined to return an Enumeration of all the
> servlet names known to this context. In this version, this method always
> returns an empty Enumeration and remains only to preserve binary
> compatibility. This method will be permanently removed in a future version
> of the Java"

Oh, yeah, should've thought to suggest just looking at the spec.  I
get a lot of my info on the spec changes from a couple of articles
Jason Hunter (author of O'Reilly's Servlets book) wrote for JavaWorld.
I don't have the exact URLs handy, but one is from December 1998 (the
one that covers the changes from 2.0 to 2.1) and one is from October
1999 (from 2.1 to 2.2) -- and that should give you an idea how old
this stuff is.


> ----- Original Message -----
> From: "Milt Epstein" <me...@uiuc.edu>
> To: <to...@jakarta.apache.org>
> Sent: Sunday, April 01, 2001 5:45 PM
> Subject: Re: getServletNames()?
> 
> 
> > On Sun, 1 Apr 2001, George Kakarontzas wrote:
> >
> > > Hi all.
> > > I have been trying to make this run:
> > > ====================================
> > > import javax.servlet.http.*;
> > >
> > > public class Loaded extends HttpServlet {
> > >
> > >   public void doGet(HttpServletRequest req, HttpServletResponse res)
> > >                                throws ServletException, IOException {
> > >     res.setContentType("text/plain");
> > >     PrintWriter out = res.getWriter();
> > >     ServletContext context = getServletContext();
> > >     Enumeration names = context.getServletNames();
> > >     while (names.hasMoreElements()) {
> > >       String name = (String)names.nextElement();
> > >       Servlet servlet = context.getServlet(name);
> > >       out.println("Servlet name: " + name);
> > >       out.println("Servlet class: " + servlet.getClass().getName());
> > >       out.println("Servlet info: " + servlet.getServletInfo());
> > >       out.println();
> > >     }
> > >   }
> > > }
> > > ========================================
> > > However the Enumeration returned by context.getServletNames() is empty!
> > > It is supposed to return the serlvets loaded (including Loaded itself).
> > > I know that this method has been deprecated in jdk1.3, which I'm
> > > using, but it should work anyway.
> > > Any suggestions?
> >
> > Why do you think it should work even if it's been deprecated?  This
> > method was deprecated long ago, in JSDK Spec 2.1, and doesn't do
> > anything anymore (like it's related method, getServlet()).
> >
> 

Milt Epstein
Research Programmer
Software/Systems Development Group
Computing and Communications Services Office (CCSO)
University of Illinois at Urbana-Champaign (UIUC)
mepstein@uiuc.edu


Re: getServletNames()?

Posted by George Kakarontzas <gk...@inf.uth.gr>.
OK Milt thanks.
I should read the spec before I ask. It clearly says:
"This method was originally defined to return an Enumeration of all the
servlet names known to this context. In this version, this method always
returns an empty Enumeration and remains only to preserve binary
compatibility. This method will be permanently removed in a future version
of the Java"

Cheers!

----- Original Message -----
From: "Milt Epstein" <me...@uiuc.edu>
To: <to...@jakarta.apache.org>
Sent: Sunday, April 01, 2001 5:45 PM
Subject: Re: getServletNames()?


> On Sun, 1 Apr 2001, George Kakarontzas wrote:
>
> > Hi all.
> > I have been trying to make this run:
> > ====================================
> > import javax.servlet.http.*;
> >
> > public class Loaded extends HttpServlet {
> >
> >   public void doGet(HttpServletRequest req, HttpServletResponse res)
> >                                throws ServletException, IOException {
> >     res.setContentType("text/plain");
> >     PrintWriter out = res.getWriter();
> >     ServletContext context = getServletContext();
> >     Enumeration names = context.getServletNames();
> >     while (names.hasMoreElements()) {
> >       String name = (String)names.nextElement();
> >       Servlet servlet = context.getServlet(name);
> >       out.println("Servlet name: " + name);
> >       out.println("Servlet class: " + servlet.getClass().getName());
> >       out.println("Servlet info: " + servlet.getServletInfo());
> >       out.println();
> >     }
> >   }
> > }
> > ========================================
> > However the Enumeration returned by context.getServletNames() is empty!
> > It is supposed to return the serlvets loaded (including Loaded itself).
> > I know that this method has been deprecated in jdk1.3, which I'm
> > using, but it should work anyway.
> > Any suggestions?
>
> Why do you think it should work even if it's been deprecated?  This
> method was deprecated long ago, in JSDK Spec 2.1, and doesn't do
> anything anymore (like it's related method, getServlet()).
>
> Milt Epstein
> Research Programmer
> Software/Systems Development Group
> Computing and Communications Services Office (CCSO)
> University of Illinois at Urbana-Champaign (UIUC)
> mepstein@uiuc.edu
>