Package edu.pdx.cs.joy.phonebillweb
Class PhoneBillServlet
java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
edu.pdx.cs.joy.phonebillweb.PhoneBillServlet
- All Implemented Interfaces:
jakarta.servlet.Servlet,jakarta.servlet.ServletConfig,Serializable
This servlet ultimately provides a REST API for working with an
PhoneBill. However, in its current state, it is an example
of how to use HTTP and Java servlets to store simple dictionary of words
and their definitions.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final String(package private) static final StringFields inherited from class jakarta.servlet.http.HttpServlet
LEGACY_DO_HEAD -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoDelete(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Handles an HTTP DELETE request by removing all dictionary entries.protected voiddoGet(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Handles an HTTP GET request from a client by writing the definition of the word specified in the "word" HTTP parameter to the HTTP response.protected voiddoPost(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Handles an HTTP POST request by storing the dictionary entry for the "word" and "definition" request parameters.(package private) StringgetDefinition(String word) voidMethods inherited from class jakarta.servlet.http.HttpServlet
doHead, doOptions, doPatch, doPut, doTrace, getLastModified, init, isSensitiveHeader, service, serviceMethods inherited from class jakarta.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log
-
Field Details
-
WORD_PARAMETER
- See Also:
-
DEFINITION_PARAMETER
- See Also:
-
-
Constructor Details
-
PhoneBillServlet
public PhoneBillServlet()
-
-
Method Details
-
doGet
protected void doGet(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws IOException Handles an HTTP GET request from a client by writing the definition of the word specified in the "word" HTTP parameter to the HTTP response. If the "word" parameter is not specified, all of the entries in the dictionary are written to the HTTP response.- Overrides:
doGetin classjakarta.servlet.http.HttpServlet- Throws:
IOException
-
doPost
protected void doPost(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws IOException Handles an HTTP POST request by storing the dictionary entry for the "word" and "definition" request parameters. It writes the dictionary entry to the HTTP response.- Overrides:
doPostin classjakarta.servlet.http.HttpServlet- Throws:
IOException
-
doDelete
protected void doDelete(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws IOException Handles an HTTP DELETE request by removing all dictionary entries. This behavior is exposed for testing purposes only. It's probably not something that you'd want a real application to expose.- Overrides:
doDeletein classjakarta.servlet.http.HttpServlet- Throws:
IOException
-
getDefinition
-
log
- Overrides:
login classjakarta.servlet.GenericServlet
-