Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Override default servlet mapping in Jetty8 with Servlet 3.0

Edgar,

You can't "override" a servlet that already has a mapping with the new
servlet 3 api. Quoting from
http://docs.oracle.com/javaee/6/api/javax/servlet/ServletRegistration.html
:

   "If any of the specified URL patterns are already mapped to a
different Servlet, no updates will be performed."

 In this case, the default servlet, mapped at "/" is configured in
webdefault.xml. If you wish to replace it, you can provide your own
webdefault.xml that has it removed.

However, be very careful replacing the default servlet unless you
understand how the mapping works - the default servlet used to serve
static content is mapped to "/" and is only invoked if every other
mapping cannot be matched against a given url.

Jan

On 2 April 2012 07:44, Edgar Espina <espina.edgar@xxxxxxxxx> wrote:
> Hi,
>
>  I'm not able to override the default servlet using Servlet 3.0 and no
> web.xml file. Here is my pom.xml:
>>
>>      <plugin>
>>         <groupId>org.mortbay.jetty</groupId>
>>         <artifactId>jetty-maven-plugin</artifactId>
>>         <version>8.1.2.v20120308</version>
>>         <configuration>
>>           <useTestScope>true</useTestScope>
>>           <webApp>
>>             <contextPath>/${project.artifactId}</contextPath>
>>           </webApp>
>>         </configuration>
>>       </plugin>
>
>
>  Main.java:
>>
>>   public class Main implements WebApplicationInitializer {
>>   @Override
>>   public void onStartup(final ServletContext servletContext)
>>       throws ServletException {
>>     ServletRegistration.Dynamic dispatcher = servletContext.addServlet(
>>         "dispatcher", new DispatcherServlet());
>>     dispatcher.setLoadOnStartup(1);
>>     dispatcher.addMapping("/");
>>   }
>> }
>
>
>  jetty:run starts without any problem or obvious errors in logs, but if I
> try to call my servlet I get a HTTP-404.
>
> I appreciate any help on this.
>
> Thanks.
>
> --
> edgar
>
> _______________________________________________
> jetty-users mailing list
> jetty-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/jetty-users
>


Back to the top