You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Nick Bauman <ni...@yahoo.com> on 2000/07/28 16:51:32 UTC

Detect servlet API? (was Bug Tracking -- note)

Is there a clean way to detect the servlet API and use
the appropriate call? Or should the older APIs go
unsupported?

--- Geoff Soutter <ge...@whitewolf.com.au> wrote:
Maybe it was designed pre 2.2 servlet API where there
was no
getContextPath() method. => pre 2.2 servlets generally
will only run in the
root context, ahh well.. it's pretty easy to port if
you have the source,
just add "getContextPath() + " wherever there was
previously
"getServletPath()"...



=====
# Nick Bauman
# Technical Programmer
# http://webhelp.com
# real software, real code, real time

__________________________________________________
Do You Yahoo!?
Kick off your party with Yahoo! Invites.
http://invites.yahoo.com/

Re: Detect servlet API? (was Bug Tracking -- note)

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Nick Bauman wrote:

> Is there a clean way to detect the servlet API and use
> the appropriate call? Or should the older APIs go
> unsupported?
>

ServletContext.getMajorVersion() and ServletContext.getMinorVersion()
will tell you what the servlet container supports.  However, if a
particular application is using a compatible subset of the method calls,
there is pretty much no way to tell what version it relies on unless
there is docco saying so that comes with the app.

In the case at hand, servlet 2.0 didn't have a concept of web
applications (or even formally specify the mapping rules for what parts
of the request URI go to what request getters).  Any app that relies on
the semantics of 2.0 (as opposed to the syntax) is going to have problems
in a 2.2 environment unless you run it in the root webapp.  Even then,
there are lots of other issues that can bite you (like the fact that
ServletContext.getServlet() now returns null unconditionally).

Craig