View Javadoc
1   package org.apache.maven.wagon.providers.http;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import javax.servlet.ServletException;
23  import javax.servlet.http.HttpServlet;
24  import javax.servlet.http.HttpServletRequest;
25  import javax.servlet.http.HttpServletResponse;
26  import java.io.IOException;
27  
28  /**
29   * User: jdumay
30   * Date: 24/01/2008
31   * Time: 17:25:27
32   */
33  public class ErrorWithMessageServlet
34      extends HttpServlet
35  {
36      private static final long serialVersionUID = -1419714266724471393L;
37  
38      public static final String MESSAGE = "it sucks!";
39  
40      public void service( HttpServletRequest request, HttpServletResponse response )
41          throws ServletException, IOException
42      {
43          if ( request.getPathInfo().endsWith( "/401" ) )
44          {
45              response.sendError( 401, MESSAGE );
46          }
47          else if ( request.getPathInfo().endsWith( "/403" ) )
48          {
49              response.sendError( 403, MESSAGE );
50          }
51          else if ( request.getPathInfo().endsWith( "/404" ) )
52          {
53              response.sendError( 404, MESSAGE );
54          }
55          else if ( request.getPathInfo().endsWith( "/407" ) )
56          {
57              response.sendError( 407, MESSAGE );
58          }
59          else if ( request.getPathInfo().endsWith( "/500" ) )
60          {
61              response.sendError( 500, MESSAGE );
62          }
63  
64      }
65  }