Class ChallengesServlet

java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
me.nickhanson.codeforge.web.ChallengesServlet
All Implemented Interfaces:
jakarta.servlet.Servlet, jakarta.servlet.ServletConfig, Serializable

@WebServlet(urlPatterns={"/challenges","/challenges/*"}) public class ChallengesServlet extends jakarta.servlet.http.HttpServlet
Servlet for handling CRUD operations on Challenge entities. Supports listing, creating, viewing, editing, and deleting challenges. URL Patterns: - GET /challenges : List all challenges (optionally filtered by difficulty) - GET /challenges/new : Show form to create a new challenge - POST /challenges : Create a new challenge - GET /challenges/{id} : View details of a specific challenge - GET /challenges/{id}/edit : Show form to edit an existing challenge - POST /challenges/{id} : Update an existing challenge - POST /challenges/{id}/delete : Delete a specific challenge
Author:
Nick Hanson
See Also:
  • Field Summary

    Fields inherited from class jakarta.servlet.http.HttpServlet

    LEGACY_DO_HEAD
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    doGet(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp)
    Handles GET requests for listing, viewing, and editing challenges.
    protected void
    doPost(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp)
    Handles POST requests for creating, updating, and deleting challenges.
    void
     

    Methods inherited from class jakarta.servlet.http.HttpServlet

    doDelete, doHead, doOptions, doPut, doTrace, getLastModified, init, service, service

    Methods inherited from class jakarta.servlet.GenericServlet

    destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, log, log

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ChallengesServlet

      public ChallengesServlet()
  • Method Details

    • init

      public void init()
      Overrides:
      init in class jakarta.servlet.GenericServlet
    • doGet

      protected void doGet(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp) throws jakarta.servlet.ServletException, IOException
      Handles GET requests for listing, viewing, and editing challenges.
      Overrides:
      doGet in class jakarta.servlet.http.HttpServlet
      Parameters:
      req - the HttpServletRequest object
      resp - the HttpServletResponse object
      Throws:
      jakarta.servlet.ServletException - the servlet exception
      IOException - the IO exception
    • doPost

      protected void doPost(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp) throws IOException
      Handles POST requests for creating, updating, and deleting challenges.
      Overrides:
      doPost in class jakarta.servlet.http.HttpServlet
      Parameters:
      req - the HttpServletRequest
      resp - the HttpServletResponse
      Throws:
      IOException - if an I/O error occurs while sending redirect or error