第12章 アプリケーション・プログラミング・インターフェイス (Application
Programming Interface)
ここに示すのは、サーブレットAPIを構成するインターフェイス、クラス、及び例外のリストである。これらのメンバとそのメソッドの詳細な記述は、Java Servlet API Reference, v2.2を参照されたい。
太字で示されているのは、本仕様書の今回のバージョンで新しくなった部分である。
表5: サーブレットAPIパッケージのサマリ |
|
Package
javax.servlet |
Packege
javax.servlet.http |
RequestDispatcher |
HttpServletRequest |
Servlet |
HttpServletResponse |
ServletConfig |
HttpSession |
ServletConftext |
HttpSessionBindingListener |
ServletRequest |
HttpSessionContext |
ServletResponse |
Cookie |
SingleThreadModel |
HttpServlet |
GenericServlet |
HttpSessionBindingEvent |
ServletInputStream |
HttpUtils |
ServletOutputStream |
|
ServletException |
|
UnavailableException |
|
12.1 Package javax.servlet
12.1.1 RequestDispatcher
public
interface RequestDispatcher
public
void forward(ServletRequest req, ServletResponse res);
public void include(ServletRequest req, ServletResponse res);
12.1.2 Servlet
public
interface Servlet
public
void init(ServletConfig config) throws ServletException;
public
ServletConfig getServletConfig();
public
void service(ServletRequest req, ServletResponse res) throws IOException,
ServletException;
public
String getServletInfo();
public void destroy();
12.1.3 ServletConfig
public
interface ServletConfig
public
ServletContext getServletContext();
public
String getInitParameter(String name);
public
Enumeration getInitParameterNames();
public
String getServletName();
12.1.4 ServletContext
public
interface ServletContext
public
String getMimeType(String filename);
public
URL getResource(String path) throws MalformedURLException;
public
InputStream getResourceAsStream(String path);
public
RequestDispatcher getRequestDispatcher(String name);
public
RequestDispatcher getNamedDispatcher(String name);
public
String getRealPath(String path);
public
ServletContext getContext(String uripath);
public
String getServerInfo();
public
String getInitParameter(String name);
public
Enumeration getInitParameterNames();
public
Object getAttribute(String name);
public
Enumeration getAttributeNames();
public
void setAttribute(String name, Object attribute);
public
void removeAttribute(String name);
public
int getMajorVersion();
public
int getMinorVersion();
public
void log(String message);
public
void log(String message, Throwable cause);
//deprecated
methods
public
Servlet getServlet(String name) throws ServletException;
public
Enumeration getServlets();
public
Enumeration getServletNames();
public
void log(Exception exception, String message);
12.1.5 ServletRequest
public
interface ServletRequest
public
Object getAttribute(String name);
public
Object getAttribute(String name, Object attribute);
public
Enumeration getAttributeNames();
public
void removeAttribute(String name);
public
Locale getLocale();
public
Enumeration getLocales();
public
String getCharacterEncoding();
public
int getContentLength();
public
String getContentType();
public
ServletInputStream getInputStream() throws IOException;
public
String getParameter(String name);
public
String getParameterNames();
public
String getParameterValues();
public
String getProtocol();
public
String getScheme();
public
String getServerName();
public
String gerServerPort();
public
BufferReader getReader() throws IOException;
public
String getRemoteAddr();
public
String getRemoteHost();
public
Boolean isSecure();
public
RequestDispatcher getRequestDispatcher(String path);
//
deprecated methods
public
String getRaelPath();
12.1.6 ServletResponse
public
interface ServletResponse
public
String getCharacterEncoding();
public
ServletOutputStream getOutputStream() throws IOException;
public
PrintWriter getPrintWriter() throws IOException;
public
void setContentLength(int length);
public
void setContentType(String type);
public
void setBufferSize(int size);
public
int getBufferSize();
public
void reset();
public
Boolean isComitted();
public
void flushBuffer() throws IOException;
public
void setLocale(Locale locale);
public
Locale getLocale();
12.1.7 SingleThreadModel
public
interface SingleThreadModel
//
no methods
12.1.8 GenericServlet
public
abstract class GenericServlet implements Servlet
public
GenericServlet();
public
String getInitParameter();
public
Enumeration getInitParameterNames();
public
ServerConfig getServerConfig();
public
ServletContext gerServletContext();
public
String getServletInfo();
public
void init();
public
void init(ServletConfig config) throws ServletException;
public
void log(String message);
public
void log(String message, Throwable cause);
public
abstract void service(ServletRequest req, ServletResponse res) throws
ServletException, IOException;
public
void destroy();
12.1.9 ServletInputStream
public
abstract class ServletInputStream extends InputStream
public
ServletInputStream();
public
int readLine(byte[] buffer, int offset, int length) throws IOException;
12.1.10 ServletOutputStream
public
abstract class ServletOutputStream extends OutputStream
public
ServletOutputStream();
public
void print(String s) throws IOException;
public
void print(Boolean b) throws IOException;
public
void print(char c) throws IOException;
public
void print(int i) throws IOException;
public
void print(long l) throws IOException;
public
void print(float f) throws IOException;
public
void print(double d) throws IOException;
public
void println() throws IOException;
public
void println(String s) throws IOException;
public
void println(boolean b) throws IOException;
public
void println(char c) throws IOException;
public
void println(int i) throws IOException;
public
void println(long l) throws IOException;
public
void println(float f) throws IOException;
public
void println(double d) throws IOException;
12.1.11 ServletException
public
class ServletException extends Exception;
public
ServletException();
public
ServletException(String message);
public
ServletException(String message, Throwable cause);
public
ServletException(Throwable cause);
public
Throwable getRootCause();
12.1.12 UnavailableException
public
class UnavailableException extends ServletException
public
UnavailableException(String message);
public
UnavailableException(String message, int sec);
public
int getUnavailableException();
public
Boolean isPermanent();
//
newly deprecated methods
public
UnavailableException(servlet servlet, String message);
public
UnavailableException(int sec, Servlet servlet, String msg);
public
Servlet getDervlet();
12.2 Package javax.servlet.http
interface
HttpServletRequest
interface
HttpServletResponse
interface
HttpSession
interface
HttpSessionBindingListener
interface
HttpSessionContext
class
cookie
class
HttpServlet
class
HttpSessionBindingEvent
class
HttpUtils
12.2.1 HttpServletRequest
public
interface HttpServletRequest extends ServletRequest;
public
String getAuthType();
public
Cookie[] getCookies();
public
long getDateHeader(String name);
public
String getHeader(String name);
public
Enumeration getHeaders(String name);
public
Enumeration getHeaderNames();
public
int getIntHeader(String name);
public
String getMethod();
public
String getContextPath();
public
String getPathInfo();
public
String getPathTranslated();
public
String getQueryString();
public
String getRemoteUser();
public
Boolean isUserInRole(String role);
public
java.sequrity.principal getUserPrincipal();
public
String getRequestedSessionId();
public
boolean isRequestedSessionIdValid();
public
Boolean isRequestedSessionIdFromCookie();
public
Boolean isRequestedSessionIdFromURL();
public
String getRequestURI();
public
String getServletPath();
public
HttpSession getSession();
public
HttpSession getSession(Boolean create);
//
deprecated methods
public
Boolean isRequestSessionIdFromUrl();
12.2.2 HttpServletResponse
public
interface HttpServletResponse extends ServletResponse
<<<
STATUS CODE 416 AND 417 REPORTED MISSING>>>
public
static final int SC_CONTINUE;
public
static final int SC_SWITCHING_PROTOCOLS;
public
static final int SC_OK;
public
static final int SC_CREATED;
public
static final int SC_ACCEPTED;
public
static final int SC_NON_AUTHORITATIVE_INFORMATION;
public
static final int SC_NO_CONTENT;
public
static final int SC_RESET_CONTENT;
public
static final int SC_PARTIAL_CONTENT;
public
static final int SC_MULTIPLE_CHOICES;
public
static final int SC_MOVED_PERMANENTLY;
public
static final int SC_MOVED_TEMPORARILY;
public
static final int SC_SEE_OTHER;
public
static final int SC_NOT_MODIFIED;
public
static final int SC_USE_PROXY;
public
static final int SC_BAD_REQUEST;
public
static final int SC_UNAUTHORIZED;
public
static final int SC_ PAYMENT_REQUIRED;
public
static final int SC_FORBIDDEN;
public
static final int SC_NOT_FOUND;
public
static final int SC_METHOD_NOT_ALLOWED;
public
static final int SC_NOT_ACCEPTABLE;
public
static final int SC_PROXY_AUTHENTICATION_REQUIRED;
public
static final int SC_REQUEST_TIMEOUT;
public
static final int SC_CONFLICT;
public
static final int SC_GONE;
public
static final int SC_ LENGTH_REQUIRED;
public
static final int SC_PRECONDITION_FAILED;
public
static final int SC_REQUEST_ENTITY_TOO_LARGE;
public
static final int SC_REQUEST_URI_TOO_LONG;
public
static final int SC_UNSUPPORTED_MEDIA_TYPE;
public
static final int SC_REQUESTED_RANGE_NOT_SATISFIABLE;
public
static final int SC_EXPECTATION_FAILED;
public
static final int SC_INTERNAL_SERVER_ERROR;
public
static final int SC_NOT_IMPLEMENTED;
public
static final int SC_BAD_GATEWAY;
public
static final int SC_SERVICE_UNAVAILABLE;
public
static final int SC_GATEWAY_TIMEOUT;
public
static final int SC_HTTP_VERSION_NOT_SUPPORTED;
public
void addCookie(Cookie cookie);
public
Boolean containsHeader(String name);
public
String encodeURL(String url);
public
String encodeRedirectURL(String url);
public
void sendError(int status) throws IOException;
public
void sendError(int status, String message) throws IOException;
public
void sendRedirect(String location) throws IOException;
public
void setDateHeader(String headername, long date);
public
void setHeader(String headername, String value);
public
void addHeader(String headername, String value);
public
void addDateHeader(String headername, long date);
public
void addIntHeader(String headername, int value);
public
void setIntHeader(String headername, int value);
public
void setStatus(int statuscode);
//
deprecated methods
public
void setStatus(int statuscode, String message);
public
String encodeUrl(String url);
public
String encodeRedirectUrl(String url);
12.2.3 HttpSession
public
interface HttpSession
public
long getCreationTime();
public
String getId();
public
long getLastAccessedTime();
public
boolean isNew();
public
int getMaxInactiveInterval();
public
void setMaxInactiveInterval(int interval);
public
Object getAttribute(String name);
public
Enumeration getAttributeNames();
public
void setAttribute(String name, Object attribute);
public
void removeAttribute(String name);
public void invalidate();
//
deprecated methods
public
Object getValue(String name);
public
String[] getValueNames();
public
void putValue(String name, Object value);
public
void removeValue(String name);
public
HttpSessionContext getSessionContext();
12.2.4 HttpSessionBindingListener
public
interface HttpSessionBindingListener extends EventListener
public
void valueBound(HttpSessionBindingEvent event);
public
void valueUnbound(HttpSessionBindingEvent event);
12.2.5 HttpSessionContext
//
deprecated
public
abstract interface HttpSessionContext
//
deprecated methods
public
void Enumeration getIds();
public
HttpSession getSession(String id);
12.2.6 Cookie
public
class Cookie implements Colnable
public
Cookie(String name, String value);
public
void setComment(String comment);
public
String getComment();
public
void setDomain(String domain);
public
String getDomain();
public
void setMaxAge(int expiry);
public
int getMaxAge();
public
void setPath(String uriPath);
public
String getPath();
public
void getSecure();
public
boolean getSecure();
public
String getName();
public
void setValue(String value);
public
String getValue();
public
int getVersion();
public
void setVersion(int version);
public
Object clone();
12.2.7 HttpServlet
public
abstract class HttpServlet extends GenericServlet implements Serializable
public
HttpServlet();
protected
void doGet(HttpServletRequest req, HttpServletResponse res) throws
ServletException, IOException;
protected
void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException,
IOException;
protected
void doPut(HttpServletRequest req, HttpServletResponse res) throws
ServletException, IOException;
protected
void doDelete(HttpServletRequest req, HttpServletResponse res) throws
ServletException, IOException;
protected
void doOptions(HttpServletRequest req, HttpServletResponse res) throws
ServletException, IOException;
protected
void doTrace(HttpServletRequest req, HttpServletResponse res) throws
ServletException, IOException;
protected
void service(HttpServletRequest req, HttpServletResponse res) throws
ServletException, IOException;
public
void service(HttpServletRequest req, HttpServletResponse res) throws
ServletException, IOException;
protected
lond getLastModified(HttpServletRequest req);
12.2.8 HttpSessionBindingEvent
public
class HttpSessionBindingEvent extends EventObject
public
HttpSessionBindingEvent(HttpSession session, String name);
public
String getName();
public
HttpSession getSession();
12.2.9 HttpUtils
public
class HttpUtils
public
HttpUtils();
public
static Hashtable parseQueryString(String queryString);
public
static Hashtable parsePostData(int length, ServletInputStream in);
public
static StringBuffer getRequestURL(HttpServletRequest req);