servlet-api-2.5-20081211

16:52:49.010 INFO  jd.cli.Main - Decompiling servlet-api-2.5-20081211.jar
package javax.servlet.http;

import java.security.Principal;
import java.util.Enumeration;
import javax.servlet.ServletRequestWrapper;

public class HttpServletRequestWrapper
  extends ServletRequestWrapper
  implements HttpServletRequest
{
  public HttpServletRequestWrapper(HttpServletRequest request)
  {
    super(request);
  }
  
  private HttpServletRequest _getHttpServletRequest()
  {
    return (HttpServletRequest)super.getRequest();
  }
  
  public String getAuthType()
  {
    return _getHttpServletRequest().getAuthType();
  }
  
  public Cookie[] getCookies()
  {
    return _getHttpServletRequest().getCookies();
  }
  
  public long getDateHeader(String name)
  {
    return _getHttpServletRequest().getDateHeader(name);
  }
  
  public String getHeader(String name)
  {
    return _getHttpServletRequest().getHeader(name);
  }
  
  public Enumeration getHeaders(String name)
  {
    return _getHttpServletRequest().getHeaders(name);
  }
  
  public Enumeration getHeaderNames()
  {
    return _getHttpServletRequest().getHeaderNames();
  }
  
  public int getIntHeader(String name)
  {
    return _getHttpServletRequest().getIntHeader(name);
  }
  
  public String getMethod()
  {
    return _getHttpServletRequest().getMethod();
  }
  
  public String getPathInfo()
  {
    return _getHttpServletRequest().getPathInfo();
  }
  
  public String getPathTranslated()
  {
    return _getHttpServletRequest().getPathTranslated();
  }
  
  public String getContextPath()
  {
    return _getHttpServletRequest().getContextPath();
  }
  
  public String getQueryString()
  {
    return _getHttpServletRequest().getQueryString();
  }
  
  public String getRemoteUser()
  {
    return _getHttpServletRequest().getRemoteUser();
  }
  
  public boolean isUserInRole(String role)
  {
    return _getHttpServletRequest().isUserInRole(role);
  }
  
  public Principal getUserPrincipal()
  {
    return _getHttpServletRequest().getUserPrincipal();
  }
  
  public String getRequestedSessionId()
  {
    return _getHttpServletRequest().getRequestedSessionId();
  }
  
  public String getRequestURI()
  {
    return _getHttpServletRequest().getRequestURI();
  }
  
  public StringBuffer getRequestURL()
  {
    return _getHttpServletRequest().getRequestURL();
  }
  
  public String getServletPath()
  {
    return _getHttpServletRequest().getServletPath();
  }
  
  public HttpSession getSession(boolean create)
  {
    return _getHttpServletRequest().getSession(create);
  }
  
  public HttpSession getSession()
  {
    return _getHttpServletRequest().getSession();
  }
  
  public boolean isRequestedSessionIdValid()
  {
    return _getHttpServletRequest().isRequestedSessionIdValid();
  }
  
  public boolean isRequestedSessionIdFromCookie()
  {
    return _getHttpServletRequest().isRequestedSessionIdFromCookie();
  }
  
  public boolean isRequestedSessionIdFromURL()
  {
    return _getHttpServletRequest().isRequestedSessionIdFromURL();
  }
  
  public boolean isRequestedSessionIdFromUrl()
  {
    return _getHttpServletRequest().isRequestedSessionIdFromUrl();
  }
}

/* Location:
 * Qualified Name:     javax.servlet.http.HttpServletRequestWrapper
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package javax.servlet.http;

import java.security.Principal;
import java.util.Enumeration;
import javax.servlet.ServletRequest;

public abstract interface HttpServletRequest
  extends ServletRequest
{
  public static final String BASIC_AUTH = "BASIC";
  public static final String FORM_AUTH = "FORM";
  public static final String CLIENT_CERT_AUTH = "CLIENT_CERT";
  public static final String DIGEST_AUTH = "DIGEST";
  
  public abstract String getAuthType();
  
  public abstract Cookie[] getCookies();
  
  public abstract long getDateHeader(String paramString);
  
  public abstract String getHeader(String paramString);
  
  public abstract Enumeration getHeaders(String paramString);
  
  public abstract Enumeration getHeaderNames();
  
  public abstract int getIntHeader(String paramString);
  
  public abstract String getMethod();
  
  public abstract String getPathInfo();
  
  public abstract String getPathTranslated();
  
  public abstract String getContextPath();
  
  public abstract String getQueryString();
  
  public abstract String getRemoteUser();
  
  public abstract boolean isUserInRole(String paramString);
  
  public abstract Principal getUserPrincipal();
  
  public abstract String getRequestedSessionId();
  
  public abstract String getRequestURI();
  
  public abstract StringBuffer getRequestURL();
  
  public abstract String getServletPath();
  
  public abstract HttpSession getSession(boolean paramBoolean);
  
  public abstract HttpSession getSession();
  
  public abstract boolean isRequestedSessionIdValid();
  
  public abstract boolean isRequestedSessionIdFromCookie();
  
  public abstract boolean isRequestedSessionIdFromURL();
  
  /**
   * @deprecated
   */
  public abstract boolean isRequestedSessionIdFromUrl();
}

/* Location:
 * Qualified Name:     javax.servlet.http.HttpServletRequest
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package javax.servlet.http;

import java.text.MessageFormat;
import java.util.ResourceBundle;

public class Cookie
  implements Cloneable
{
  private static final String LSTRING_FILE = "javax.servlet.http.LocalStrings";
  private static ResourceBundle lStrings = ResourceBundle.getBundle("javax.servlet.http.LocalStrings");
  private String name;
  private String value;
  private String comment;
  private String domain;
  private int maxAge = -1;
  private String path;
  private boolean secure;
  private int version = 0;
  private static final String tspecials = ",; ";
  
  public Cookie(String name, String value)
  {
    if ((!isToken(name)) || (name.equalsIgnoreCase("Comment")) || (name.equalsIgnoreCase("Discard")) || (name.equalsIgnoreCase("Domain")) || (name.equalsIgnoreCase("Expires")) || (name.equalsIgnoreCase("Max-Age")) || (name.equalsIgnoreCase("Path")) || (name.equalsIgnoreCase("Secure")) || (name.equalsIgnoreCase("Version")) || (name.startsWith("$")))
    {
      String errMsg = lStrings.getString("err.cookie_name_is_token");
      Object[] errArgs = new Object[1];
      errArgs[0] = name;
      errMsg = MessageFormat.format(errMsg, errArgs);
      throw new IllegalArgumentException(errMsg);
    }
    this.name = name;
    this.value = value;
  }
  
  public void setComment(String purpose)
  {
    comment = purpose;
  }
  
  public String getComment()
  {
    return comment;
  }
  
  public void setDomain(String pattern)
  {
    domain = pattern.toLowerCase();
  }
  
  public String getDomain()
  {
    return domain;
  }
  
  public void setMaxAge(int expiry)
  {
    maxAge = expiry;
  }
  
  public int getMaxAge()
  {
    return maxAge;
  }
  
  public void setPath(String uri)
  {
    path = uri;
  }
  
  public String getPath()
  {
    return path;
  }
  
  public void setSecure(boolean flag)
  {
    secure = flag;
  }
  
  public boolean getSecure()
  {
    return secure;
  }
  
  public String getName()
  {
    return name;
  }
  
  public void setValue(String newValue)
  {
    value = newValue;
  }
  
  public String getValue()
  {
    return value;
  }
  
  public int getVersion()
  {
    return version;
  }
  
  public void setVersion(int v)
  {
    version = v;
  }
  
  private boolean isToken(String value)
  {
    int len = value.length();
    for (int i = 0; i < len; i++)
    {
      char c = value.charAt(i);
      if ((c < ' ') || (c >= '') || (",; ".indexOf(c) != -1)) {
        return false;
      }
    }
    return true;
  }
  
  public Object clone()
  {
    try
    {
      return super.clone();
    }
    catch (CloneNotSupportedException e)
    {
      throw new RuntimeException(e.getMessage());
    }
  }
}

/* Location:
 * Qualified Name:     javax.servlet.http.Cookie
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package javax.servlet.http;

import java.util.Enumeration;
import javax.servlet.ServletContext;

public abstract interface HttpSession
{
  public abstract long getCreationTime();
  
  public abstract String getId();
  
  public abstract long getLastAccessedTime();
  
  public abstract ServletContext getServletContext();
  
  public abstract void setMaxInactiveInterval(int paramInt);
  
  public abstract int getMaxInactiveInterval();
  
  /**
   * @deprecated
   */
  public abstract HttpSessionContext getSessionContext();
  
  public abstract Object getAttribute(String paramString);
  
  /**
   * @deprecated
   */
  public abstract Object getValue(String paramString);
  
  public abstract Enumeration getAttributeNames();
  
  /**
   * @deprecated
   */
  public abstract String[] getValueNames();
  
  public abstract void setAttribute(String paramString, Object paramObject);
  
  /**
   * @deprecated
   */
  public abstract void putValue(String paramString, Object paramObject);
  
  public abstract void removeAttribute(String paramString);
  
  /**
   * @deprecated
   */
  public abstract void removeValue(String paramString);
  
  public abstract void invalidate();
  
  public abstract boolean isNew();
}

/* Location:
 * Qualified Name:     javax.servlet.http.HttpSession
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package javax.servlet.http;

import java.util.Enumeration;

/**
 * @deprecated
 */
public abstract interface HttpSessionContext
{
  /**
   * @deprecated
   */
  public abstract HttpSession getSession(String paramString);
  
  /**
   * @deprecated
   */
  public abstract Enumeration getIds();
}

/* Location:
 * Qualified Name:     javax.servlet.http.HttpSessionContext
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package javax.servlet.http;

import java.util.EventListener;

public abstract interface HttpSessionBindingListener
  extends EventListener
{
  public abstract void valueBound(HttpSessionBindingEvent paramHttpSessionBindingEvent);
  
  public abstract void valueUnbound(HttpSessionBindingEvent paramHttpSessionBindingEvent);
}

/* Location:
 * Qualified Name:     javax.servlet.http.HttpSessionBindingListener
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package javax.servlet.http;

public class HttpSessionBindingEvent
  extends HttpSessionEvent
{
  private String name;
  private Object value;
  
  public HttpSessionBindingEvent(HttpSession session, String name)
  {
    super(session);
    this.name = name;
  }
  
  public HttpSessionBindingEvent(HttpSession session, String name, Object value)
  {
    super(session);
    this.name = name;
    this.value = value;
  }
  
  public HttpSession getSession()
  {
    return super.getSession();
  }
  
  public String getName()
  {
    return name;
  }
  
  public Object getValue()
  {
    return value;
  }
}

/* Location:
 * Qualified Name:     javax.servlet.http.HttpSessionBindingEvent
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package javax.servlet.http;

import java.util.EventObject;

public class HttpSessionEvent
  extends EventObject
{
  public HttpSessionEvent(HttpSession source)
  {
    super(source);
  }
  
  public HttpSession getSession()
  {
    return (HttpSession)super.getSource();
  }
}

/* Location:
 * Qualified Name:     javax.servlet.http.HttpSessionEvent
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package javax.servlet.http;

import java.util.EventListener;

public abstract interface HttpSessionActivationListener
  extends EventListener
{
  public abstract void sessionWillPassivate(HttpSessionEvent paramHttpSessionEvent);
  
  public abstract void sessionDidActivate(HttpSessionEvent paramHttpSessionEvent);
}

/* Location:
 * Qualified Name:     javax.servlet.http.HttpSessionActivationListener
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package javax.servlet.http;

import java.io.IOException;
import javax.servlet.ServletResponse;

public abstract interface HttpServletResponse
  extends ServletResponse
{
  public static final int SC_CONTINUE = 100;
  public static final int SC_SWITCHING_PROTOCOLS = 101;
  public static final int SC_OK = 200;
  public static final int SC_CREATED = 201;
  public static final int SC_ACCEPTED = 202;
  public static final int SC_NON_AUTHORITATIVE_INFORMATION = 203;
  public static final int SC_NO_CONTENT = 204;
  public static final int SC_RESET_CONTENT = 205;
  public static final int SC_PARTIAL_CONTENT = 206;
  public static final int SC_MULTIPLE_CHOICES = 300;
  public static final int SC_MOVED_PERMANENTLY = 301;
  public static final int SC_MOVED_TEMPORARILY = 302;
  public static final int SC_FOUND = 302;
  public static final int SC_SEE_OTHER = 303;
  public static final int SC_NOT_MODIFIED = 304;
  public static final int SC_USE_PROXY = 305;
  public static final int SC_TEMPORARY_REDIRECT = 307;
  public static final int SC_BAD_REQUEST = 400;
  public static final int SC_UNAUTHORIZED = 401;
  public static final int SC_PAYMENT_REQUIRED = 402;
  public static final int SC_FORBIDDEN = 403;
  public static final int SC_NOT_FOUND = 404;
  public static final int SC_METHOD_NOT_ALLOWED = 405;
  public static final int SC_NOT_ACCEPTABLE = 406;
  public static final int SC_PROXY_AUTHENTICATION_REQUIRED = 407;
  public static final int SC_REQUEST_TIMEOUT = 408;
  public static final int SC_CONFLICT = 409;
  public static final int SC_GONE = 410;
  public static final int SC_LENGTH_REQUIRED = 411;
  public static final int SC_PRECONDITION_FAILED = 412;
  public static final int SC_REQUEST_ENTITY_TOO_LARGE = 413;
  public static final int SC_REQUEST_URI_TOO_LONG = 414;
  public static final int SC_UNSUPPORTED_MEDIA_TYPE = 415;
  public static final int SC_REQUESTED_RANGE_NOT_SATISFIABLE = 416;
  public static final int SC_EXPECTATION_FAILED = 417;
  public static final int SC_INTERNAL_SERVER_ERROR = 500;
  public static final int SC_NOT_IMPLEMENTED = 501;
  public static final int SC_BAD_GATEWAY = 502;
  public static final int SC_SERVICE_UNAVAILABLE = 503;
  public static final int SC_GATEWAY_TIMEOUT = 504;
  public static final int SC_HTTP_VERSION_NOT_SUPPORTED = 505;
  
  public abstract void addCookie(Cookie paramCookie);
  
  public abstract boolean containsHeader(String paramString);
  
  public abstract String encodeURL(String paramString);
  
  public abstract String encodeRedirectURL(String paramString);
  
  /**
   * @deprecated
   */
  public abstract String encodeUrl(String paramString);
  
  /**
   * @deprecated
   */
  public abstract String encodeRedirectUrl(String paramString);
  
  public abstract void sendError(int paramInt, String paramString)
    throws IOException;
  
  public abstract void sendError(int paramInt)
    throws IOException;
  
  public abstract void sendRedirect(String paramString)
    throws IOException;
  
  public abstract void setDateHeader(String paramString, long paramLong);
  
  public abstract void addDateHeader(String paramString, long paramLong);
  
  public abstract void setHeader(String paramString1, String paramString2);
  
  public abstract void addHeader(String paramString1, String paramString2);
  
  public abstract void setIntHeader(String paramString, int paramInt);
  
  public abstract void addIntHeader(String paramString, int paramInt);
  
  public abstract void setStatus(int paramInt);
  
  /**
   * @deprecated
   */
  public abstract void setStatus(int paramInt, String paramString);
}

/* Location:
 * Qualified Name:     javax.servlet.http.HttpServletResponse
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package javax.servlet.http;

import java.io.IOException;
import java.io.Serializable;
import java.lang.reflect.Method;
import java.text.MessageFormat;
import java.util.Enumeration;
import java.util.ResourceBundle;
import javax.servlet.GenericServlet;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

public abstract class HttpServlet
  extends GenericServlet
  implements Serializable
{
  private static final String METHOD_DELETE = "DELETE";
  private static final String METHOD_HEAD = "HEAD";
  private static final String METHOD_GET = "GET";
  private static final String METHOD_OPTIONS = "OPTIONS";
  private static final String METHOD_POST = "POST";
  private static final String METHOD_PUT = "PUT";
  private static final String METHOD_TRACE = "TRACE";
  private static final String HEADER_IFMODSINCE = "If-Modified-Since";
  private static final String HEADER_LASTMOD = "Last-Modified";
  private static final String LSTRING_FILE = "javax.servlet.http.LocalStrings";
  private static ResourceBundle lStrings = ResourceBundle.getBundle("javax.servlet.http.LocalStrings");
  
  protected void doGet(HttpServletRequest req, HttpServletResponse resp)
    throws ServletException, IOException
  {
    String protocol = req.getProtocol();
    String msg = lStrings.getString("http.method_get_not_supported");
    if (protocol.endsWith("1.1")) {
      resp.sendError(405, msg);
    } else {
      resp.sendError(400, msg);
    }
  }
  
  protected long getLastModified(HttpServletRequest req)
  {
    return -1L;
  }
  
  protected void doHead(HttpServletRequest req, HttpServletResponse resp)
    throws ServletException, IOException
  {
    NoBodyResponse response = new NoBodyResponse(resp);
    
    doGet(req, response);
    response.setContentLength();
  }
  
  protected void doPost(HttpServletRequest req, HttpServletResponse resp)
    throws ServletException, IOException
  {
    String protocol = req.getProtocol();
    String msg = lStrings.getString("http.method_post_not_supported");
    if (protocol.endsWith("1.1")) {
      resp.sendError(405, msg);
    } else {
      resp.sendError(400, msg);
    }
  }
  
  protected void doPut(HttpServletRequest req, HttpServletResponse resp)
    throws ServletException, IOException
  {
    String protocol = req.getProtocol();
    String msg = lStrings.getString("http.method_put_not_supported");
    if (protocol.endsWith("1.1")) {
      resp.sendError(405, msg);
    } else {
      resp.sendError(400, msg);
    }
  }
  
  protected void doDelete(HttpServletRequest req, HttpServletResponse resp)
    throws ServletException, IOException
  {
    String protocol = req.getProtocol();
    String msg = lStrings.getString("http.method_delete_not_supported");
    if (protocol.endsWith("1.1")) {
      resp.sendError(405, msg);
    } else {
      resp.sendError(400, msg);
    }
  }
  
  private Method[] getAllDeclaredMethods(Class c)
  {
    if (c.equals(HttpServlet.class)) {
      return null;
    }
    Method[] parentMethods = getAllDeclaredMethods(c.getSuperclass());
    Method[] thisMethods = c.getDeclaredMethods();
    if ((parentMethods != null) && (parentMethods.length > 0))
    {
      Method[] allMethods = new Method[parentMethods.length + thisMethods.length];
      
      System.arraycopy(parentMethods, 0, allMethods, 0, parentMethods.length);
      
      System.arraycopy(thisMethods, 0, allMethods, parentMethods.length, thisMethods.length);
      
      thisMethods = allMethods;
    }
    return thisMethods;
  }
  
  protected void doOptions(HttpServletRequest req, HttpServletResponse resp)
    throws ServletException, IOException
  {
    Method[] methods = getAllDeclaredMethods(getClass());
    
    boolean ALLOW_GET = false;
    boolean ALLOW_HEAD = false;
    boolean ALLOW_POST = false;
    boolean ALLOW_PUT = false;
    boolean ALLOW_DELETE = false;
    boolean ALLOW_TRACE = true;
    boolean ALLOW_OPTIONS = true;
    for (int i = 0; i < methods.length; i++)
    {
      Method m = methods[i];
      if (m.getName().equals("doGet"))
      {
        ALLOW_GET = true;
        ALLOW_HEAD = true;
      }
      if (m.getName().equals("doPost")) {
        ALLOW_POST = true;
      }
      if (m.getName().equals("doPut")) {
        ALLOW_PUT = true;
      }
      if (m.getName().equals("doDelete")) {
        ALLOW_DELETE = true;
      }
    }
    String allow = null;
    if ((ALLOW_GET) && 
      (allow == null)) {
      allow = "GET";
    }
    if (ALLOW_HEAD) {
      if (allow == null) {
        allow = "HEAD";
      } else {
        allow = allow + ", HEAD";
      }
    }
    if (ALLOW_POST) {
      if (allow == null) {
        allow = "POST";
      } else {
        allow = allow + ", POST";
      }
    }
    if (ALLOW_PUT) {
      if (allow == null) {
        allow = "PUT";
      } else {
        allow = allow + ", PUT";
      }
    }
    if (ALLOW_DELETE) {
      if (allow == null) {
        allow = "DELETE";
      } else {
        allow = allow + ", DELETE";
      }
    }
    if (ALLOW_TRACE) {
      if (allow == null) {
        allow = "TRACE";
      } else {
        allow = allow + ", TRACE";
      }
    }
    if (ALLOW_OPTIONS) {
      if (allow == null) {
        allow = "OPTIONS";
      } else {
        allow = allow + ", OPTIONS";
      }
    }
    resp.setHeader("Allow", allow);
  }
  
  protected void doTrace(HttpServletRequest req, HttpServletResponse resp)
    throws ServletException, IOException
  {
    String CRLF = "\r\n";
    String responseString = "TRACE " + req.getRequestURI() + " " + req.getProtocol();
    
    Enumeration reqHeaderEnum = req.getHeaderNames();
    while (reqHeaderEnum.hasMoreElements())
    {
      String headerName = (String)reqHeaderEnum.nextElement();
      responseString = responseString + CRLF + headerName + ": " + req.getHeader(headerName);
    }
    responseString = responseString + CRLF;
    
    int responseLength = responseString.length();
    
    resp.setContentType("message/http");
    resp.setContentLength(responseLength);
    ServletOutputStream out = resp.getOutputStream();
    out.print(responseString);
    out.close();
  }
  
  protected void service(HttpServletRequest req, HttpServletResponse resp)
    throws ServletException, IOException
  {
    String method = req.getMethod();
    if (method.equals("GET"))
    {
      long lastModified = getLastModified(req);
      if (lastModified == -1L)
      {
        doGet(req, resp);
      }
      else
      {
        long ifModifiedSince = req.getDateHeader("If-Modified-Since");
        if (ifModifiedSince < lastModified / 1000L * 1000L)
        {
          maybeSetLastModified(resp, lastModified);
          doGet(req, resp);
        }
        else
        {
          resp.setStatus(304);
        }
      }
    }
    else if (method.equals("HEAD"))
    {
      long lastModified = getLastModified(req);
      maybeSetLastModified(resp, lastModified);
      doHead(req, resp);
    }
    else if (method.equals("POST"))
    {
      doPost(req, resp);
    }
    else if (method.equals("PUT"))
    {
      doPut(req, resp);
    }
    else if (method.equals("DELETE"))
    {
      doDelete(req, resp);
    }
    else if (method.equals("OPTIONS"))
    {
      doOptions(req, resp);
    }
    else if (method.equals("TRACE"))
    {
      doTrace(req, resp);
    }
    else
    {
      String errMsg = lStrings.getString("http.method_not_implemented");
      Object[] errArgs = new Object[1];
      errArgs[0] = method;
      errMsg = MessageFormat.format(errMsg, errArgs);
      
      resp.sendError(501, errMsg);
    }
  }
  
  private void maybeSetLastModified(HttpServletResponse resp, long lastModified)
  {
    if (resp.containsHeader("Last-Modified")) {
      return;
    }
    if (lastModified >= 0L) {
      resp.setDateHeader("Last-Modified", lastModified);
    }
  }
  
  public void service(ServletRequest req, ServletResponse res)
    throws ServletException, IOException
  {
    HttpServletRequest request;
    HttpServletResponse response;
    try
    {
      request = (HttpServletRequest)req;
      response = (HttpServletResponse)res;
    }
    catch (ClassCastException e)
    {
      throw new ServletException("non-HTTP request or response");
    }
    service(request, response);
  }
}

/* Location:
 * Qualified Name:     javax.servlet.http.HttpServlet
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package javax.servlet.http;

import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.Locale;
import javax.servlet.ServletOutputStream;

class NoBodyResponse
  implements HttpServletResponse
{
  private HttpServletResponse resp;
  private NoBodyOutputStream noBody;
  private PrintWriter writer;
  private boolean didSetContentLength;
  
  NoBodyResponse(HttpServletResponse r)
  {
    resp = r;
    noBody = new NoBodyOutputStream();
  }
  
  void setContentLength()
  {
    if (!didSetContentLength) {
      resp.setContentLength(noBody.getContentLength());
    }
  }
  
  public void setContentLength(int len)
  {
    resp.setContentLength(len);
    didSetContentLength = true;
  }
  
  public void setCharacterEncoding(String charset)
  {
    resp.setCharacterEncoding(charset);
  }
  
  public void setContentType(String type)
  {
    resp.setContentType(type);
  }
  
  public String getContentType()
  {
    return resp.getContentType();
  }
  
  public ServletOutputStream getOutputStream()
    throws IOException
  {
    return noBody;
  }
  
  public String getCharacterEncoding()
  {
    return resp.getCharacterEncoding();
  }
  
  public PrintWriter getWriter()
    throws UnsupportedEncodingException
  {
    if (writer == null)
    {
      OutputStreamWriter w = new OutputStreamWriter(noBody, getCharacterEncoding());
      writer = new PrintWriter(w);
    }
    return writer;
  }
  
  public void setBufferSize(int size)
    throws IllegalStateException
  {
    resp.setBufferSize(size);
  }
  
  public int getBufferSize()
  {
    return resp.getBufferSize();
  }
  
  public void reset()
    throws IllegalStateException
  {
    resp.reset();
  }
  
  public void resetBuffer()
    throws IllegalStateException
  {
    resp.resetBuffer();
  }
  
  public boolean isCommitted()
  {
    return resp.isCommitted();
  }
  
  public void flushBuffer()
    throws IOException
  {
    resp.flushBuffer();
  }
  
  public void setLocale(Locale loc)
  {
    resp.setLocale(loc);
  }
  
  public Locale getLocale()
  {
    return resp.getLocale();
  }
  
  public void addCookie(Cookie cookie)
  {
    resp.addCookie(cookie);
  }
  
  public boolean containsHeader(String name)
  {
    return resp.containsHeader(name);
  }
  
  /**
   * @deprecated
   */
  public void setStatus(int sc, String sm)
  {
    resp.setStatus(sc, sm);
  }
  
  public void setStatus(int sc)
  {
    resp.setStatus(sc);
  }
  
  public void setHeader(String name, String value)
  {
    resp.setHeader(name, value);
  }
  
  public void setIntHeader(String name, int value)
  {
    resp.setIntHeader(name, value);
  }
  
  public void setDateHeader(String name, long date)
  {
    resp.setDateHeader(name, date);
  }
  
  public void sendError(int sc, String msg)
    throws IOException
  {
    resp.sendError(sc, msg);
  }
  
  public void sendError(int sc)
    throws IOException
  {
    resp.sendError(sc);
  }
  
  public void sendRedirect(String location)
    throws IOException
  {
    resp.sendRedirect(location);
  }
  
  public String encodeURL(String url)
  {
    return resp.encodeURL(url);
  }
  
  public String encodeRedirectURL(String url)
  {
    return resp.encodeRedirectURL(url);
  }
  
  public void addHeader(String name, String value)
  {
    resp.addHeader(name, value);
  }
  
  public void addDateHeader(String name, long value)
  {
    resp.addDateHeader(name, value);
  }
  
  public void addIntHeader(String name, int value)
  {
    resp.addIntHeader(name, value);
  }
  
  /**
   * @deprecated
   */
  public String encodeUrl(String url)
  {
    return encodeURL(url);
  }
  
  /**
   * @deprecated
   */
  public String encodeRedirectUrl(String url)
  {
    return encodeRedirectURL(url);
  }
}

/* Location:
 * Qualified Name:     javax.servlet.http.NoBodyResponse
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package javax.servlet.http;

import java.io.IOException;
import java.util.ResourceBundle;
import javax.servlet.ServletOutputStream;

class NoBodyOutputStream
  extends ServletOutputStream
{
  private static final String LSTRING_FILE = "javax.servlet.http.LocalStrings";
  private static ResourceBundle lStrings = ResourceBundle.getBundle("javax.servlet.http.LocalStrings");
  private int contentLength = 0;
  
  int getContentLength()
  {
    return contentLength;
  }
  
  public void write(int b)
  {
    contentLength += 1;
  }
  
  public void write(byte[] buf, int offset, int len)
    throws IOException
  {
    if (len >= 0)
    {
      contentLength += len;
    }
    else
    {
      String msg = lStrings.getString("err.io.negativelength");
      throw new IOException("negative length");
    }
  }
}

/* Location:
 * Qualified Name:     javax.servlet.http.NoBodyOutputStream
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package javax.servlet.http;

import java.io.IOException;
import javax.servlet.ServletResponseWrapper;

public class HttpServletResponseWrapper
  extends ServletResponseWrapper
  implements HttpServletResponse
{
  public HttpServletResponseWrapper(HttpServletResponse response)
  {
    super(response);
  }
  
  private HttpServletResponse _getHttpServletResponse()
  {
    return (HttpServletResponse)super.getResponse();
  }
  
  public void addCookie(Cookie cookie)
  {
    _getHttpServletResponse().addCookie(cookie);
  }
  
  public boolean containsHeader(String name)
  {
    return _getHttpServletResponse().containsHeader(name);
  }
  
  public String encodeURL(String url)
  {
    return _getHttpServletResponse().encodeURL(url);
  }
  
  public String encodeRedirectURL(String url)
  {
    return _getHttpServletResponse().encodeRedirectURL(url);
  }
  
  public String encodeUrl(String url)
  {
    return _getHttpServletResponse().encodeUrl(url);
  }
  
  public String encodeRedirectUrl(String url)
  {
    return _getHttpServletResponse().encodeRedirectUrl(url);
  }
  
  public void sendError(int sc, String msg)
    throws IOException
  {
    _getHttpServletResponse().sendError(sc, msg);
  }
  
  public void sendError(int sc)
    throws IOException
  {
    _getHttpServletResponse().sendError(sc);
  }
  
  public void sendRedirect(String location)
    throws IOException
  {
    _getHttpServletResponse().sendRedirect(location);
  }
  
  public void setDateHeader(String name, long date)
  {
    _getHttpServletResponse().setDateHeader(name, date);
  }
  
  public void addDateHeader(String name, long date)
  {
    _getHttpServletResponse().addDateHeader(name, date);
  }
  
  public void setHeader(String name, String value)
  {
    _getHttpServletResponse().setHeader(name, value);
  }
  
  public void addHeader(String name, String value)
  {
    _getHttpServletResponse().addHeader(name, value);
  }
  
  public void setIntHeader(String name, int value)
  {
    _getHttpServletResponse().setIntHeader(name, value);
  }
  
  public void addIntHeader(String name, int value)
  {
    _getHttpServletResponse().addIntHeader(name, value);
  }
  
  public void setStatus(int sc)
  {
    _getHttpServletResponse().setStatus(sc);
  }
  
  public void setStatus(int sc, String sm)
  {
    _getHttpServletResponse().setStatus(sc, sm);
  }
}

/* Location:
 * Qualified Name:     javax.servlet.http.HttpServletResponseWrapper
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package javax.servlet.http;

import java.util.EventListener;

public abstract interface HttpSessionListener
  extends EventListener
{
  public abstract void sessionCreated(HttpSessionEvent paramHttpSessionEvent);
  
  public abstract void sessionDestroyed(HttpSessionEvent paramHttpSessionEvent);
}

/* Location:
 * Qualified Name:     javax.servlet.http.HttpSessionListener
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package javax.servlet.http;

import java.util.EventListener;

public abstract interface HttpSessionAttributeListener
  extends EventListener
{
  public abstract void attributeAdded(HttpSessionBindingEvent paramHttpSessionBindingEvent);
  
  public abstract void attributeRemoved(HttpSessionBindingEvent paramHttpSessionBindingEvent);
  
  public abstract void attributeReplaced(HttpSessionBindingEvent paramHttpSessionBindingEvent);
}

/* Location:
 * Qualified Name:     javax.servlet.http.HttpSessionAttributeListener
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package javax.servlet.http;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Hashtable;
import java.util.ResourceBundle;
import java.util.StringTokenizer;
import javax.servlet.ServletInputStream;

/**
 * @deprecated
 */
public class HttpUtils
{
  private static final String LSTRING_FILE = "javax.servlet.http.LocalStrings";
  private static ResourceBundle lStrings = ResourceBundle.getBundle("javax.servlet.http.LocalStrings");
  
  public static Hashtable parseQueryString(String s)
  {
    String[] valArray = null;
    if (s == null) {
      throw new IllegalArgumentException();
    }
    Hashtable ht = new Hashtable();
    StringBuffer sb = new StringBuffer();
    StringTokenizer st = new StringTokenizer(s, "&");
    while (st.hasMoreTokens())
    {
      String pair = st.nextToken();
      int pos = pair.indexOf('=');
      if (pos == -1) {
        throw new IllegalArgumentException();
      }
      String key = parseName(pair.substring(0, pos), sb);
      String val = parseName(pair.substring(pos + 1, pair.length()), sb);
      if (ht.containsKey(key))
      {
        String[] oldVals = (String[])ht.get(key);
        valArray = new String[oldVals.length + 1];
        for (int i = 0; i < oldVals.length; i++) {
          valArray[i] = oldVals[i];
        }
        valArray[oldVals.length] = val;
      }
      else
      {
        valArray = new String[1];
        valArray[0] = val;
      }
      ht.put(key, valArray);
    }
    return ht;
  }
  
  public static Hashtable parsePostData(int len, ServletInputStream in)
  {
    if (len <= 0) {
      return new Hashtable();
    }
    if (in == null) {
      throw new IllegalArgumentException();
    }
    byte[] postedBytes = new byte[len];
    try
    {
      int offset = 0;
      do
      {
        int inputLen = in.read(postedBytes, offset, len - offset);
        if (inputLen <= 0)
        {
          String msg = lStrings.getString("err.io.short_read");
          throw new IllegalArgumentException(msg);
        }
        offset += inputLen;
      } while (len - offset > 0);
    }
    catch (IOException e)
    {
      throw new IllegalArgumentException(e.getMessage());
    }
    try
    {
      String postedBody = new String(postedBytes, 0, len, "8859_1");
      return parseQueryString(postedBody);
    }
    catch (UnsupportedEncodingException e)
    {
      throw new IllegalArgumentException(e.getMessage());
    }
  }
  
  private static String parseName(String s, StringBuffer sb)
  {
    sb.setLength(0);
    for (int i = 0; i < s.length(); i++)
    {
      char c = s.charAt(i);
      switch (c)
      {
      case '+': 
        sb.append(' ');
        break;
      case '%': 
        try
        {
          sb.append((char)Integer.parseInt(s.substring(i + 1, i + 3), 16));
          
          i += 2;
        }
        catch (NumberFormatException e)
        {
          throw new IllegalArgumentException();
        }
        catch (StringIndexOutOfBoundsException e)
        {
          String rest = s.substring(i);
          sb.append(rest);
          if (rest.length() == 2) {
            i++;
          }
        }
      default: 
        sb.append(c);
      }
    }
    return sb.toString();
  }
  
  public static StringBuffer getRequestURL(HttpServletRequest req)
  {
    StringBuffer url = new StringBuffer();
    String scheme = req.getScheme();
    int port = req.getServerPort();
    String urlPath = req.getRequestURI();
    
    url.append(scheme);
    url.append("://");
    url.append(req.getServerName());
    if (((scheme.equals("http")) && (port != 80)) || ((scheme.equals("https")) && (port != 443)))
    {
      url.append(':');
      url.append(req.getServerPort());
    }
    url.append(urlPath);
    return url;
  }
}

/* Location:
 * Qualified Name:     javax.servlet.http.HttpUtils
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package javax.servlet;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Enumeration;
import java.util.Locale;
import java.util.Map;

public class ServletRequestWrapper
  implements ServletRequest
{
  private ServletRequest request;
  
  public ServletRequestWrapper(ServletRequest request)
  {
    if (request == null) {
      throw new IllegalArgumentException("Request cannot be null");
    }
    this.request = request;
  }
  
  public ServletRequest getRequest()
  {
    return request;
  }
  
  public void setRequest(ServletRequest request)
  {
    if (request == null) {
      throw new IllegalArgumentException("Request cannot be null");
    }
    this.request = request;
  }
  
  public Object getAttribute(String name)
  {
    return request.getAttribute(name);
  }
  
  public Enumeration getAttributeNames()
  {
    return request.getAttributeNames();
  }
  
  public String getCharacterEncoding()
  {
    return request.getCharacterEncoding();
  }
  
  public void setCharacterEncoding(String enc)
    throws UnsupportedEncodingException
  {
    request.setCharacterEncoding(enc);
  }
  
  public int getContentLength()
  {
    return request.getContentLength();
  }
  
  public String getContentType()
  {
    return request.getContentType();
  }
  
  public ServletInputStream getInputStream()
    throws IOException
  {
    return request.getInputStream();
  }
  
  public String getParameter(String name)
  {
    return request.getParameter(name);
  }
  
  public Map getParameterMap()
  {
    return request.getParameterMap();
  }
  
  public Enumeration getParameterNames()
  {
    return request.getParameterNames();
  }
  
  public String[] getParameterValues(String name)
  {
    return request.getParameterValues(name);
  }
  
  public String getProtocol()
  {
    return request.getProtocol();
  }
  
  public String getScheme()
  {
    return request.getScheme();
  }
  
  public String getServerName()
  {
    return request.getServerName();
  }
  
  public int getServerPort()
  {
    return request.getServerPort();
  }
  
  public BufferedReader getReader()
    throws IOException
  {
    return request.getReader();
  }
  
  public String getRemoteAddr()
  {
    return request.getRemoteAddr();
  }
  
  public String getRemoteHost()
  {
    return request.getRemoteHost();
  }
  
  public void setAttribute(String name, Object o)
  {
    request.setAttribute(name, o);
  }
  
  public void removeAttribute(String name)
  {
    request.removeAttribute(name);
  }
  
  public Locale getLocale()
  {
    return request.getLocale();
  }
  
  public Enumeration getLocales()
  {
    return request.getLocales();
  }
  
  public boolean isSecure()
  {
    return request.isSecure();
  }
  
  public RequestDispatcher getRequestDispatcher(String path)
  {
    return request.getRequestDispatcher(path);
  }
  
  public String getRealPath(String path)
  {
    return request.getRealPath(path);
  }
  
  public int getRemotePort()
  {
    return request.getRemotePort();
  }
  
  public String getLocalName()
  {
    return request.getLocalName();
  }
  
  public String getLocalAddr()
  {
    return request.getLocalAddr();
  }
  
  public int getLocalPort()
  {
    return request.getLocalPort();
  }
}

/* Location:
 * Qualified Name:     javax.servlet.ServletRequestWrapper
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package javax.servlet;

import java.io.Buffere
1 2

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd