SERVLET:::
void destroy() Called by the servlet container to indicate to a servlet that the servlet is being taken out of service. ServletConfig getServletConfig() Returns a ServletConfig object, which contains initialization and startup parameters for this servlet. java.lang.String getServletInfo() Returns information about the servlet, such as author, version, and copyright. void init(ServletConfig config) Called by the servlet container to indicate to a servlet that the servlet is being placed into service. void service(ServletRequest req, ServletResponse res) Called by the servlet container to allow the servlet to respond to a request.
HTTP SERVLET:::
protected void doDelete(HttpServletRequest req, HttpServletResponse resp)
Called by the server (via the service method) to allow a servlet to handle a DELETE request. protected void doGet(HttpServletRequest req, HttpServletResponse resp)
Called by the server (via the service method) to allow a servlet to handle a GET request.
protected void
doHead(HttpServletRequest req, HttpServletResponse resp)
Receives an HTTP HEAD request from the protected service method and handles the request. protected void doOptions(HttpServletRequest req, HttpServletResponse resp)
Called by the server (via the service method) to allow a servlet to handle a OPTIONS request. protected void doPost(HttpServletRequest req, HttpServletResponse resp)
Called by the server (via the service method) to allow a servlet to handle a POST request. protected void doPut(HttpServletRequest req, HttpServletResponse resp)
Called by the server (via the service method) to allow a servlet to handle a PUT request. protected void doTrace(HttpServletRequest req, HttpServletResponse resp)
Called by the server (via the service method) to allow a servlet to handle a TRACE request. protected long getLastModified(HttpServletRequest req)
Returns the time the HttpServletRequest object was last modified, in milliseconds since midnight January 1, 1970 GMT. protected void service(HttpServletRequest req, HttpServletResponse resp)
Receives standard HTTP requests from the public service method and dispatches them to the doXXX methods defined in this class. void service(ServletRequest req, ServletResponse res) Dispatches client requests to the protected service method.
GENERIC SERVLET:::
void destroy() Called by the servlet container to indicate to a servlet that the servlet is being taken out of service. java.lang.String getInitParameter(java.lang.String name) Returns a String containing the value of the named Initialization parameter, or null if the parameter does not exist. java.util.Enumeration getInitParameterNames()
Returns the names of the servlet's initialization parameters as an Enumeration of String objects, or an empty Enumeration if the servlet has no initialization parameters. ServletConfig getServletConfig() Returns this servlet's ServletConfig object. ServletContext getServletContext()
Returns a reference to the ServletContext in which this servlet is running. java.lang.String getServletInfo()
Returns information about the servlet, such as author, version, and copyright. java.lang.String getServletName()
Returns the name of this servlet instance. void init() A convenience method which can be overridden so that there's no need to call super.init(config).
void
init(ServletConfig config) Called by the servlet container to indicate to a servlet that the servlet is being placed into service.
void log(java.lang.String msg) Writes the specified message to a servlet log file, prepended by the servlet's name. void log(java.lang.String message, java.lang.Throwable t) Writes an explanatory message and a stack trace for a given Throwable exception to the servlet log file, prepended by the servlet's name. abstract void service(ServletRequest req, ServletResponse res) Called by the servlet container to allow the servlet to respond to a request.
HTTP SERVLET REQUEST:::
java.lang.String getAuthType()
Returns the name of the authentication scheme used to protect the servlet. java.lang.String getContextPath()
Returns the portion of the request URI that indicates the context of the request. Cookie[] getCookies()
Returns an array containing all of the Cookie objects the client sent with this request.
long getDateHeader(java.lang.String name) Returns the value of the specified request header as a long value that represents a Date object. java.lang.String getHeader(java.lang.String name)
Returns the value of the specified request header as a String. java.util.Enumeration getHeaderNames()
Returns an enumeration of all the header names this request contains. java.util.Enumeration getHeaders(java.lang.String name)
Returns all the values of the specified request header as an Enumeration of String objects. int getIntHeader(java.lang.String name) Returns the value of the specified request header as an int. java.lang.String getMethod()
Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT. java.lang.String getPathInfo()
Returns any extra path information associated with the URL the client sent when it made this request. java.lang.String getPathTranslated()
Returns any extra path information after the servlet name but before the query string, and translates it to a real path.
java.lang.String
getQueryString()
Returns the query string that is contained in the request URL after the path. java.lang.String getRemoteUser()
Returns the login of the user making this request, if the user has been authenticated, or null if the user has not been authenticated. java.lang.String getRequestedSessionId()
Returns the session ID specified by the client. java.lang.String getRequestURI()
Returns the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request. java.lang.StringBuffer getRequestURL()
Reconstructs the URL the client used to make the request. java.lang.String getServletPath()
Returns the part of this request's URL that calls the servlet. HttpSession getSession() Returns the current session associated with this request, or if the request does not have a session, creates one. HttpSession getSession(boolean create) Returns the current HttpSession associated with this request or, if there is no current session and create is true, returns a new session.
java.security.Principal
getUserPrincipal()
Returns a java.security.Principal object containing the name of the current authenticated user. boolean isRequestedSessionIdFromCookie()
Checks whether the requested session ID came in as a cookie. boolean isRequestedSessionIdFromUrl()
Deprecated. As of Version 2.1 of the Java Servlet API, use isRequestedSessionIdFromURL() instead. boolean isRequestedSessionIdFromURL()
Checks whether the requested session ID came in as part of the request URL. boolean isRequestedSessionIdValid()
Checks whether the requested session ID is still valid. boolean isUserInRole(java.lang.String role)
Returns a boolean indicating whether the authenticated user is included in the specified logical "role".
HTTP SERVLET RESPONSE::: SERVLET CONFIG:::
java.lang.String getInitParameter(java.lang.String name)
Returns a String containing the value of the named initialization parameter, or null if the parameter does not exist.
java.util.Enumeration
getInitParameterNames()
Returns the names of the servlet's initialization parameters as an Enumeration of String objects, or an empty Enumeration if the servlet has no initialization parameters. ServletContext getServletContext()
Returns a reference to the ServletContext in which the caller is executing. java.lang.String getServletName()
Returns the name of this servlet instance.
SERVLET CONTEXT:::
java.lang.Object getAttribute(java.lang.String name)
Returns the servlet container attribute with the given name, or null if there is no attribute by that name. java.util.Enumeration getAttributeNames()
Returns an Enumeration containing the attribute names available within this servlet context. ServletContext getContext(java.lang.String uripath)
Returns a ServletContext object that corresponds to a specified URL on the server. java.lang.String getInitParameter(java.lang.String name)
Returns a String containing the value of the named context-wide initialization parameter, or null if the parameter does not exist.
java.util.Enumeration
getInitParameterNames()
Returns the names of the context's initialization parameters as an Enumeration of String objects, or an empty Enumeration if the context has no initialization parameters. int getMajorVersion() Returns the major version of the Java Servlet API that this servlet container supports. java.lang.String getMimeType(java.lang.String file)
Returns the MIME type of the specified file, or null if the MIME type is not known. int getMinorVersion() Returns the minor version of the Servlet API that this servlet container supports. RequestDispatcher getNamedDispatcher(java.lang.String name) Returns a RequestDispatcher object that acts as a wrapper for the named servlet. java.lang.String getRealPath(java.lang.String path)
Returns a String containing the real path for a given virtual path. RequestDispatcher getRequestDispatcher(java.lang.String path) Returns a RequestDispatcher object that acts as a wrapper for the resource located at the given path. java.net.URL getResource(java.lang.String path) Returns a URL to the resource that is mapped to a specified path.
java.io.InputStream getResourceAsStream(java.lang.String path) Returns the resource located at the named path as an Input Stream object. java.util.Set getResourcePaths(java.lang.String path) Returns a directory-like listing of all the paths to resources within the web application whose longest sub-path matches the supplied path argument. java.lang.String getServerInfo()
Returns the name and version of the servlet container on which the servlet is running. Servlet getServlet(java.lang.String name) Deprecated. As of Java Servlet API 2.1, with no direct replacement.This method was originally defined to retrieve a servlet from a ServletContext java.lang.String getServletContextName()
Returns the name of this web application corresponding to this ServletContext as specified in the deployment descriptor for this web application by the display-name element. java.util.Enumeration getServletNames()
Deprecated. As of Java Servlet API 2.1, with no replacement. This method was originally defined to return an Enumeration of all the servlet names known to this context. In this version, this method always returns an empty Enumeration and remains only to preserve binary compatibility.
java.util.Enumeration
getServlets()
Deprecated. As of Java Servlet API 2.0, with no replacement. This method was originally defined to return an Enumeration of a ll the servlets known to this servlet context. In this version, this method always returns an empty enumeration and remains only to preserve binary compatibility. This method will be permanently removed in a future version of the Java Servlet API. void log(java.lang.Exception exception, java.lang.String msg) Deprecated. As of Java Servlet API 2.1, use log(String message, Throwable throwable) instead. void log(java.lang.String msg) Writes the specified message to a servlet log file, usually an event log. void log(java.lang.String message, java.lang.Throwable throwable) Writes an explanatory message and a stack trace for a given Throwable exception to the servlet log file. void removeAttribute(java.lang.String name) Removes the attribute with the given name from the servlet context. void setAttribute(java.lang.String name, java.lang.Object object) Binds an object to a given attribute name in this servlet context.