Class ExampleServlet
- java.lang.Object
-
- jakarta.servlet.GenericServlet
-
- jakarta.servlet.http.HttpServlet
-
- de.kosmos_lab.web.server.servlets.ExampleServlet
-
- All Implemented Interfaces:
jakarta.servlet.Servlet,jakarta.servlet.ServletConfig,Serializable
- Direct Known Subclasses:
AuthedServlet,HelloWorldServlet,LoginServlet,OnlineServlet
public class ExampleServlet extends jakarta.servlet.http.HttpServlet- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected static org.slf4j.Loggerloggerprotected static Patternpattern_hostprotected ExampleWebServerserverprotected static intSTATUS_CONFLICTprotected static intSTATUS_ERRORprotected static intSTATUS_FAILEDprotected static intSTATUS_FORBIDDENprotected static intSTATUS_METHOD_NOT_ALLOWEDprotected static intSTATUS_NO_AUTHprotected static intSTATUS_NO_RESPONSEprotected static intSTATUS_NOT_FOUNDprotected static intSTATUS_OKprotected static intSTATUS_UNPROCESSABLE
-
Constructor Summary
Constructors Constructor Description ExampleServlet(ExampleWebServer server)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddCORSHeader(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp)protected booleancheckParameter(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse response, String[] keys)voiddelete(MyHttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)voiddoDelete(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)voiddoGet(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)voiddoOptions(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)voiddoPost(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)voiddoPut(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)voidget(MyHttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)protected booleanisAllowed(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)voidoptions(MyHttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)voidpost(MyHttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)voidput(MyHttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)protected voidsendJSON(MyHttpServletRequest req, jakarta.servlet.http.HttpServletResponse response, org.json.JSONArray obj)protected voidsendJSON(MyHttpServletRequest req, jakarta.servlet.http.HttpServletResponse response, org.json.JSONObject obj)protected voidsendJWT(MyHttpServletRequest req, jakarta.servlet.http.HttpServletResponse response, String text)protected voidsendText(MyHttpServletRequest req, jakarta.servlet.http.HttpServletResponse response, String text)protected voidsendXML(MyHttpServletRequest req, jakarta.servlet.http.HttpServletResponse response, String text)-
Methods inherited from class jakarta.servlet.http.HttpServlet
doHead, doTrace, getLastModified, service, service
-
-
-
-
Field Detail
-
logger
protected static final org.slf4j.Logger logger
-
STATUS_OK
protected static final int STATUS_OK
- See Also:
- Constant Field Values
-
STATUS_NO_RESPONSE
protected static final int STATUS_NO_RESPONSE
- See Also:
- Constant Field Values
-
STATUS_FORBIDDEN
protected static final int STATUS_FORBIDDEN
- See Also:
- Constant Field Values
-
STATUS_FAILED
protected static final int STATUS_FAILED
- See Also:
- Constant Field Values
-
STATUS_NO_AUTH
protected static final int STATUS_NO_AUTH
- See Also:
- Constant Field Values
-
STATUS_NOT_FOUND
protected static final int STATUS_NOT_FOUND
- See Also:
- Constant Field Values
-
STATUS_CONFLICT
protected static final int STATUS_CONFLICT
- See Also:
- Constant Field Values
-
STATUS_UNPROCESSABLE
protected static final int STATUS_UNPROCESSABLE
- See Also:
- Constant Field Values
-
STATUS_ERROR
protected static final int STATUS_ERROR
- See Also:
- Constant Field Values
-
STATUS_METHOD_NOT_ALLOWED
protected static final int STATUS_METHOD_NOT_ALLOWED
- See Also:
- Constant Field Values
-
pattern_host
protected static final Pattern pattern_host
-
server
protected final ExampleWebServer server
-
-
Constructor Detail
-
ExampleServlet
public ExampleServlet(ExampleWebServer server)
-
-
Method Detail
-
addCORSHeader
protected void addCORSHeader(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp)
-
checkParameter
protected boolean checkParameter(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse response, String[] keys) throws IOException- Throws:
IOException
-
delete
public void delete(MyHttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws jakarta.servlet.ServletException, IOException, ParameterNotFoundException, NotFoundException
- Throws:
jakarta.servlet.ServletExceptionIOExceptionParameterNotFoundExceptionNotFoundException
-
doDelete
public void doDelete(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws jakarta.servlet.ServletException, IOException- Overrides:
doDeletein classjakarta.servlet.http.HttpServlet- Throws:
jakarta.servlet.ServletExceptionIOException
-
doGet
public void doGet(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws jakarta.servlet.ServletException, IOException- Overrides:
doGetin classjakarta.servlet.http.HttpServlet- Throws:
jakarta.servlet.ServletExceptionIOException
-
doOptions
public void doOptions(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws jakarta.servlet.ServletException, IOException- Overrides:
doOptionsin classjakarta.servlet.http.HttpServlet- Throws:
jakarta.servlet.ServletExceptionIOException
-
doPost
public void doPost(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws jakarta.servlet.ServletException, IOException- Overrides:
doPostin classjakarta.servlet.http.HttpServlet- Throws:
jakarta.servlet.ServletExceptionIOException
-
doPut
public void doPut(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws jakarta.servlet.ServletException, IOException- Overrides:
doPutin classjakarta.servlet.http.HttpServlet- Throws:
jakarta.servlet.ServletExceptionIOException
-
get
public void get(MyHttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws jakarta.servlet.ServletException, IOException, ParameterNotFoundException, NotFoundException, LoginFailedException, UnauthorizedException, NoPersistenceException
- Throws:
jakarta.servlet.ServletExceptionIOExceptionParameterNotFoundExceptionNotFoundExceptionLoginFailedExceptionUnauthorizedExceptionNoPersistenceException
-
isAllowed
protected boolean isAllowed(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)
-
options
public void options(MyHttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)
-
post
public void post(MyHttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws jakarta.servlet.ServletException, IOException, ParameterNotFoundException, NotFoundException, UnauthorizedException, NoSuchAlgorithmException, InvalidKeyException, NoPersistenceException, LoginFailedException
- Throws:
jakarta.servlet.ServletExceptionIOExceptionParameterNotFoundExceptionNotFoundExceptionUnauthorizedExceptionNoSuchAlgorithmExceptionInvalidKeyExceptionNoPersistenceExceptionLoginFailedException
-
put
public void put(MyHttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws jakarta.servlet.ServletException, IOException, ParameterNotFoundException, NotFoundException, LoginFailedException, UnauthorizedException
- Throws:
jakarta.servlet.ServletExceptionIOExceptionParameterNotFoundExceptionNotFoundExceptionLoginFailedExceptionUnauthorizedException
-
sendJSON
protected void sendJSON(MyHttpServletRequest req, jakarta.servlet.http.HttpServletResponse response, org.json.JSONObject obj) throws IOException
- Throws:
IOException
-
sendJSON
protected void sendJSON(MyHttpServletRequest req, jakarta.servlet.http.HttpServletResponse response, org.json.JSONArray obj) throws IOException
- Throws:
IOException
-
sendJWT
protected void sendJWT(MyHttpServletRequest req, jakarta.servlet.http.HttpServletResponse response, String text) throws IOException
- Throws:
IOException
-
sendText
protected void sendText(MyHttpServletRequest req, jakarta.servlet.http.HttpServletResponse response, String text) throws IOException
- Throws:
IOException
-
sendXML
protected void sendXML(MyHttpServletRequest req, jakarta.servlet.http.HttpServletResponse response, String text) throws IOException
- Throws:
IOException
-
-