From: <bc...@wo...> - 2001-03-29 18:03:52
|
[Kent Johnson] >I am trying out PyServlet using Jetty 2, a web server that implements >the 2.1 servlet spec, and I have a little problem. > >The value of request.getServletPath() is different in 2.1 and 2.2 in >a way that breaks PyServlet. Under 2.1, when the servlet is matched >by an extension match, getServletPath() returns null. Under 2.2, it >returns the entire path through the matched extension. > >The Servlet 2.1 spec says, > >public String getServletPath(); >[snip] >If the servlet was invoked by some other mechanism than by a path >match (such as >an extension match), then this method returns null. > >whereas the 2.2 spec has the example > >Servlet Mapping Pattern: *.jsp >Servlet: JSPServlet >/catalog/help/feedback.jsp ContextPath: /catalog >ServletPath: /help/feedback.jsp >PathInfo: null > >To make PyServlet work with Jetty I changed line 108 to read > spath = ((HttpServletRequest) req).getServletPath() + >((HttpServletRequest) req).getPathInfo(); I don't understand how this patch can work. To me that ends up with values like spath = "null/help/feedback.py" or spath = "/help/feedback.pynull" depending on which getter that reurned null. >i think this will work under both 2.1 and 2.2, though I have not >tested it with 2.2. I would rather do something like this, if that works for you: spath = ((HttpServletRequest) req).getServletPath(); if (spath == null) { // Servlet1.1 puts thr path of an extension-matched // servlet in PathInfo. spath = ((HttpServletRequest) req).getPathInfo(); } regards, finn |