You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ErrorServlet.java 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright (C) 2010, Google Inc. and others
  3. *
  4. * This program and the accompanying materials are made available under the
  5. * terms of the Eclipse Distribution License v. 1.0 which is available at
  6. * https://www.eclipse.org/org/documents/edl-v10.php.
  7. *
  8. * SPDX-License-Identifier: BSD-3-Clause
  9. */
  10. package org.eclipse.jgit.http.server.glue;
  11. import java.io.IOException;
  12. import javax.servlet.ServletException;
  13. import javax.servlet.http.HttpServlet;
  14. import javax.servlet.http.HttpServletRequest;
  15. import javax.servlet.http.HttpServletResponse;
  16. /**
  17. * Send a fixed status code to the client.
  18. */
  19. public class ErrorServlet extends HttpServlet {
  20. private static final long serialVersionUID = 1L;
  21. private final int status;
  22. /**
  23. * Sends a specific status code.
  24. *
  25. * @param status
  26. * the HTTP status code to always send.
  27. */
  28. public ErrorServlet(int status) {
  29. this.status = status;
  30. }
  31. /** {@inheritDoc} */
  32. @Override
  33. protected void doGet(HttpServletRequest req, HttpServletResponse rsp)
  34. throws ServletException, IOException {
  35. rsp.sendError(status);
  36. }
  37. }