users@servlet-spec.java.net

[servlet-spec users] Re: Implementation of new Servlet functionality?

From: arjan tijms <arjan.tijms_at_gmail.com>
Date: Wed, 30 Mar 2016 01:04:43 +0200

Hi,

Sorry that it took somewhat longer. The Mojarra build is a little less
trivial and I tried to get Tomcat 9 to work in Eclipse for easy debugging
but it didn't support it yet (eventually found out there's a WTP milestone
build that had Tomcat 9 support)

Anyway, it seems to work really great! I used the following test Servlet:

@WebServlet({"/exact", "/path/*", "*.ext"})
public class Servlet extends HttpServlet {
private static final long serialVersionUID = 1L;

protected void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
Mapping mapping = request.getMapping();
response.getWriter()
.append("Mapping match:")
.append(mapping.getMatchType().name())
.append("\n")
.append("Match value:")
.append(mapping.getMatchValue())
.append("\n")
.append("Pattern:")
.append(mapping.getPattern());
}

}

Calling with http://localhost:8080/servlet4/bla.ext

Prints:

Mapping match:EXTENSION
Match value:/bla
Pattern:*.ext

Calling with http://localhost:8080/servlet4/path/bla

Prints:

Mapping match:PATH
Match value:/bla
Pattern:/path/*


Calling with http://localhost:8080/servlet4/exact

Prints:

Mapping match:EXACT
Match value:/exact
Pattern:/exact

I'm planning to write a blog post about this next and add a sample/test for
it at the Java EE 8 samples project. Is the Tomcat 9 m4 Servlet jar in
Maven central or other Maven repo?

A question is how to proceed with this feature for other Servlet
containers, but that's probably best discussed at the Servlet EG list.

Kind regards,
Arjan Tijms













On Tue, Mar 29, 2016 at 8:26 AM, Mark Thomas <markt_at_apache.org> wrote:

> Any feedback on this?
>
> Mark
>
>
> On 17/03/2016 10:39, arjan tijms wrote:
> > Hi,
> >
> > That's really great! I'll do some testing over the weekend and let you
> know.
> >
> > Thanks again
> >
> > Kind regards,
> > Arjan Tijms
> >
> >
> > On Thu, Mar 17, 2016 at 11:11 AM, Mark Thomas <markt_at_apache.org
> > <mailto:markt_at_apache.org>> wrote:
> >
> > On 07/03/2016 22:32, arjan tijms wrote:
> > > Hi,
> > >
> > > On Mon, Mar 7, 2016 at 10:03 PM, Mark Thomas <markt_at_apache.org
> <mailto:markt_at_apache.org>
> > > <mailto:markt_at_apache.org <mailto:markt_at_apache.org>>> wrote:
> > >
> > > I can look at implementing this in Tomcat if that would be any
> use.
> > >
> > >
> > > That would be a great step for sure.
> > >
> > > For me personally using it for Mojarra is a big use case, and its
> tests
> > > run primarily against GlassFish, but I could sure build a personal
> test
> > > bed based on Tomcat (in fact, we already have this for OmniFaces
> ;)).
> > >
> > > So if you can look at this that would be great :)
> >
> > I've implemented this in 9.0.0.M4 available here:
> > http://tomcat.apache.org/download-90.cgi
> >
> > As always, feedback appreciated.
> >
> > Mark
> >
> >
>
>