You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dj...@apache.org on 2009/06/25 00:05:50 UTC
svn commit: r788194 [4/6] - in
/geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet:
./ annotation/ annotation/jaxrs/ http/ http/annotation/
Modified: geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/SessionCookieConfig.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/SessionCookieConfig.java?rev=788194&r1=788193&r2=788194&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/SessionCookieConfig.java (original)
+++ geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/SessionCookieConfig.java Wed Jun 24 22:05:48 2009
@@ -26,13 +26,36 @@
*/
public interface SessionCookieConfig {
+ String getComment();
+
String getDomain();
- String getPath();
+ /**
+ *
+ * @return max age in seconds for this session cookie
+ */
+ int getMaxAge();
- String getComment();
+ String getName();
+
+ String getPath();
boolean isHttpOnly();
boolean isSecure();
+
+ void setComment(String comment);
+
+ void setDomain(String domain);
+
+ void setHttpOnly(boolean httpOnly);
+
+ void setMaxAge(int maxAge);
+
+ void setName(String name);
+
+ void setPath(String path);
+
+ void setSecure(boolean secure);
+
}
Modified: geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/SingleThreadModel.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/SingleThreadModel.java?rev=788194&r1=788193&r2=788194&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/SingleThreadModel.java (original)
+++ geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/SingleThreadModel.java Wed Jun 24 22:05:48 2009
@@ -40,9 +40,7 @@
* the block of the code accessing those resources.
* This interface is deprecated in Servlet API version 2.4.
*
- *
- * @author Various
- * @version $Version$
+ * @version $Rev$ $Date$
*
* @deprecated As of Java Servlet API 2.4, with no direct
* replacement.
Modified: geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/UnavailableException.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/UnavailableException.java?rev=788194&r1=788193&r2=788194&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/UnavailableException.java (original)
+++ geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/UnavailableException.java Wed Jun 24 22:05:48 2009
@@ -43,18 +43,14 @@
* of time suggested by the exception, rather than rejecting them until
* the servlet container restarts.
*
- *
- * @author Various
- * @version $Version$
- *
+ * @version $Rev$ $Date$
*/
-public class UnavailableException
-extends ServletException {
+public class UnavailableException extends ServletException {
- private Servlet servlet; // what's unavailable
- private boolean permanent; // needs admin action?
- private int seconds; // unavailability estimate
+ private final Servlet servlet; // what's unavailable
+ private final boolean permanent; // needs admin action?
+ private final int seconds; // unavailability estimate
/**
*
@@ -68,11 +64,11 @@
* descriptive message
*
*/
-
public UnavailableException(Servlet servlet, String msg) {
super(msg);
this.servlet = servlet;
permanent = true;
+ seconds = -1;
}
/**
@@ -91,7 +87,6 @@
* displayed for the user.
*
*/
-
public UnavailableException(int seconds, Servlet servlet, String msg) {
super(msg);
this.servlet = servlet;
@@ -112,11 +107,11 @@
* descriptive message
*
*/
-
public UnavailableException(String msg) {
super(msg);
-
+ servlet = null;
permanent = true;
+ seconds = -1;
}
/**
@@ -140,10 +135,9 @@
* can't make an estimate
*
*/
-
public UnavailableException(String msg, int seconds) {
super(msg);
-
+ servlet = null;
if (seconds <= 0)
this.seconds = -1;
else
@@ -165,7 +159,6 @@
* unavailable
*
*/
-
public boolean isPermanent() {
return permanent;
}
@@ -179,7 +172,6 @@
* throwing the <code>UnavailableException</code>
*
*/
-
public Servlet getServlet() {
return servlet;
}
@@ -200,8 +192,8 @@
* unavailable or cannot make an estimate
*
*/
-
public int getUnavailableSeconds() {
return permanent ? -1 : seconds;
}
+
}
Modified: geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/FilterMapping.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/FilterMapping.java?rev=788194&r1=786616&r2=788194&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/FilterMapping.java (original)
+++ geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/FilterMapping.java Wed Jun 24 22:05:48 2009
@@ -18,7 +18,7 @@
*/
-package javax.servlet.http.annotation;
+package javax.servlet.annotation;
import java.lang.annotation.Target;
import java.lang.annotation.ElementType;
@@ -28,7 +28,7 @@
import javax.servlet.DispatcherType;
/**
- * @version $Rev:$ $Date:$
+ * @version $Rev$ $Date$
* @since 3.0
*/
Added: geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/HandlesTypes.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/HandlesTypes.java?rev=788194&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/HandlesTypes.java (added)
+++ geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/HandlesTypes.java Wed Jun 24 22:05:48 2009
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package javax.servlet.annotation;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.ElementType;
+
+/**
+ * @version $Rev$ $Date$
+ * @since 3.0
+ */
+
+@Target(value = ElementType.TYPE)
+@Retention(value = RetentionPolicy.RUNTIME)
+public @interface HandlesTypes {
+
+ Class[] value();
+
+}
Propchange: geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/HandlesTypes.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/HandlesTypes.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/HandlesTypes.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/MultipartConfig.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/MultipartConfig.java?rev=788194&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/MultipartConfig.java (added)
+++ geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/MultipartConfig.java Wed Jun 24 22:05:48 2009
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package javax.servlet.annotation;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * @version $Rev$ $Date$
+ * @since 3.0
+ */
+
+@Target(value = ElementType.TYPE)
+@Retention(value = RetentionPolicy.RUNTIME)
+public @interface MultipartConfig {
+
+ int fileSizeThreshhold() default 0;
+
+ String location() default "";
+
+ long maxFileSize() default 0L;
+
+ long maxRequestSize() default 0L;
+
+}
Propchange: geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/MultipartConfig.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/MultipartConfig.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/MultipartConfig.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/WebFilter.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/WebFilter.java?rev=788194&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/WebFilter.java (added)
+++ geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/WebFilter.java Wed Jun 24 22:05:48 2009
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package javax.servlet.annotation;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+import javax.servlet.DispatcherType;
+
+/**
+ * @version $Rev$ $Date$
+ * @since 3.0
+ */
+
+@Target(value= ElementType.TYPE)
+@Retention(value= RetentionPolicy.RUNTIME)
+public @interface WebFilter {
+
+ boolean asyncSupported();
+
+ String description() default "";
+
+ DispatcherType[] dispatcherTypes() default DispatcherType.REQUEST;
+
+ String displayName() default "";
+
+ String filterName() default "";
+
+ WebInitParam[] initParams() default {};
+
+ String largeIcon() default "";
+
+ String[] servletNames() default {};
+
+ String smallIcon() default "";
+
+ String[] urlPatterns() default {};
+
+ String[] value() default {};
+
+
+
+
+
+
+
+}
Propchange: geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/WebFilter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/WebFilter.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/WebFilter.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/WebInitParam.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/WebInitParam.java?rev=788194&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/WebInitParam.java (added)
+++ geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/WebInitParam.java Wed Jun 24 22:05:48 2009
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package javax.servlet.annotation;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * @version $Rev$ $Date$
+ */
+
+@Target(value= ElementType.TYPE)
+@Retention(value= RetentionPolicy.RUNTIME)
+public @interface WebInitParam {
+
+ String description() default "";
+
+ String name();
+
+ String value();
+
+}
Propchange: geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/WebInitParam.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/WebInitParam.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/WebInitParam.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/WebListener.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/WebListener.java?rev=788194&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/WebListener.java (added)
+++ geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/WebListener.java Wed Jun 24 22:05:48 2009
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package javax.servlet.annotation;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * @version $Rev$ $Date$
+ * @since 3.0
+ */
+
+@Target(value= ElementType.TYPE)
+@Retention(value= RetentionPolicy.RUNTIME)
+public @interface WebListener {
+
+ String description() default "";
+}
Propchange: geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/WebListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/WebListener.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/WebListener.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/WebServlet.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/WebServlet.java?rev=788194&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/WebServlet.java (added)
+++ geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/WebServlet.java Wed Jun 24 22:05:48 2009
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package javax.servlet.annotation;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * @version $Rev$ $Date$
+ * @since 3.0
+ */
+
+@Target(value= ElementType.TYPE)
+@Retention(value= RetentionPolicy.RUNTIME)
+public @interface WebServlet {
+
+ boolean asyncSupported() default false;
+
+ String description() default "";
+
+ WebInitParam[] initParams() default {};
+
+ String largeIcon() default "";
+
+ int loadOnStartup() default -1;
+
+ String name() default "";
+
+ String smallIcon() default "";
+
+ String[] urlPatterns() default {};
+
+ String[] value() default {};
+
+}
Propchange: geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/WebServlet.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/WebServlet.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/annotation/WebServlet.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/http/Cookie.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/http/Cookie.java?rev=788194&r1=788193&r2=788194&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/http/Cookie.java (original)
+++ geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/http/Cookie.java Wed Jun 24 22:05:48 2009
@@ -23,43 +23,39 @@
import java.util.ResourceBundle;
/**
- *
- * Creates a cookie, a small amount of information sent by a servlet to
+ * Creates a cookie, a small amount of information sent by a servlet to
* a Web browser, saved by the browser, and later sent back to the server.
- * A cookie's value can uniquely
+ * A cookie's value can uniquely
* identify a client, so cookies are commonly used for session management.
- *
+ * <p/>
* <p>A cookie has a name, a single value, and optional attributes
* such as a comment, path and domain qualifiers, a maximum age, and a
- * version number. Some Web browsers have bugs in how they handle the
- * optional attributes, so use them sparingly to improve the interoperability
+ * version number. Some Web browsers have bugs in how they handle the
+ * optional attributes, so use them sparingly to improve the interoperability
* of your servlets.
- *
+ * <p/>
* <p>The servlet sends cookies to the browser by using the
* {@link HttpServletResponse#addCookie} method, which adds
- * fields to HTTP response headers to send cookies to the
- * browser, one at a time. The browser is expected to
+ * fields to HTTP response headers to send cookies to the
+ * browser, one at a time. The browser is expected to
* support 20 cookies for each Web server, 300 cookies total, and
* may limit cookie size to 4 KB each.
- *
- * <p>The browser returns cookies to the servlet by adding
+ * <p/>
+ * <p>The browser returns cookies to the servlet by adding
* fields to HTTP request headers. Cookies can be retrieved
* from a request by using the {@link HttpServletRequest#getCookies} method.
* Several cookies might have the same name but different path attributes.
- *
- * <p>Cookies affect the caching of the Web pages that use them.
+ * <p/>
+ * <p>Cookies affect the caching of the Web pages that use them.
* HTTP 1.0 does not cache pages that use cookies created with
* this class. This class does not support the cache control
* defined with HTTP 1.1.
- *
- * <p>This class supports both the Version 0 (by Netscape) and Version 1
+ * <p/>
+ * <p>This class supports both the Version 0 (by Netscape) and Version 1
* (by RFC 2109) cookie specifications. By default, cookies are
* created using Version 0 to ensure the best interoperability.
*
- *
- * @author Various
- * @version $Version$
- *
+ * @version $Rev$ $Date$
*/
// XXX would implement java.io.Serializable too, but can't do that
@@ -69,430 +65,313 @@
public class Cookie implements Cloneable {
private static final String LSTRING_FILE =
- "javax.servlet.http.LocalStrings";
+ "javax.servlet.http.LocalStrings";
private static ResourceBundle lStrings =
- ResourceBundle.getBundle(LSTRING_FILE);
-
+ ResourceBundle.getBundle(LSTRING_FILE);
+
+ // Note -- disabled for now to allow full Netscape compatibility
+ // from RFC 2068, token special case characters
+ //
+ // private static final String tspecials = "()<>@,;:\\\"/[]?={} \t";
+
+ private static final String tspecials = ",; ";
+
//
// The value of the cookie itself.
//
-
- private String name; // NAME= ... "$Name" style is reserved
- private String value; // value of NAME
+
+ private String name; // NAME= ... "$Name" style is reserved
+ private String value; // value of NAME
//
// Attributes encoded in the header's cookie fields.
//
-
- private String comment; // ;Comment=VALUE ... describes cookie's use
- // ;Discard ... implied by maxAge < 0
- private String domain; // ;Domain=VALUE ... domain that sees cookie
- private int maxAge = -1; // ;Max-Age=VALUE ... cookies auto-expire
- private String path; // ;Path=VALUE ... URLs that see the cookie
- private boolean secure; // ;Secure ... e.g. use SSL
- private int version = 0; // ;Version=1 ... means RFC 2109++ style
- private boolean httpOnly;
+ private String comment; // ;Comment=VALUE ... describes cookie's use
+ // ;Discard ... implied by maxAge < 0
+ private String domain; // ;Domain=VALUE ... domain that sees cookie
+ private int maxAge = -1; // ;Max-Age=VALUE ... cookies auto-expire
+ private String path; // ;Path=VALUE ... URLs that see the cookie
+ private boolean secure; // ;Secure ... e.g. use SSL
+ private int version = 0; // ;Version=1 ... means RFC 2109++ style
+ private boolean httpOnly;
/**
* Constructs a cookie with a specified name and value.
- *
- * <p>The name must conform to RFC 2109. That means it can contain
- * only ASCII alphanumeric characters and cannot contain commas,
+ * <p/>
+ * <p>The name must conform to RFC 2109. That means it can contain
+ * only ASCII alphanumeric characters and cannot contain commas,
* semicolons, or white space or begin with a $ character. The cookie's
* name cannot be changed after creation.
- *
+ * <p/>
* <p>The value can be anything the server chooses to send. Its
* value is probably of interest only to the server. The cookie's
* value can be changed after creation with the
* <code>setValue</code> method.
- *
+ * <p/>
* <p>By default, cookies are created according to the Netscape
- * cookie specification. The version can be changed with the
+ * cookie specification. The version can be changed with the
* <code>setVersion</code> method.
*
- *
- * @param name a <code>String</code> specifying the name of the cookie
- *
- * @param value a <code>String</code> specifying the value of the cookie
- *
- * @throws IllegalArgumentException if the cookie name contains illegal characters
- * (for example, a comma, space, or semicolon)
- * or it is one of the tokens reserved for use
- * by the cookie protocol
+ * @param name a <code>String</code> specifying the name of the cookie
+ * @param value a <code>String</code> specifying the value of the cookie
+ * @throws IllegalArgumentException if the cookie name contains illegal characters
+ * (for example, a comma, space, or semicolon)
+ * or it is one of the tokens reserved for use
+ * by the cookie protocol
* @see #setValue
* @see #setVersion
- *
*/
-
public Cookie(String name, String value) {
- if (!isToken(name)
- || name.equalsIgnoreCase("Comment") // rfc2019
- || name.equalsIgnoreCase("Discard") // 2019++
- || name.equalsIgnoreCase("Domain")
- || name.equalsIgnoreCase("Expires") // (old cookies)
- || name.equalsIgnoreCase("Max-Age") // rfc2019
- || 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);
- }
+ if (!isToken(name)
+ || name.equalsIgnoreCase("Comment") // rfc2019
+ || name.equalsIgnoreCase("Discard") // 2019++
+ || name.equalsIgnoreCase("Domain")
+ || name.equalsIgnoreCase("Expires") // (old cookies)
+ || name.equalsIgnoreCase("Max-Age") // rfc2019
+ || 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;
+ this.name = name;
+ this.value = value;
}
-
-
-
-
/**
- *
* Specifies a comment that describes a cookie's purpose.
- * The comment is useful if the browser presents the cookie
+ * The comment is useful if the browser presents the cookie
* to the user. Comments
* are not supported by Netscape Version 0 cookies.
*
- * @param purpose a <code>String</code> specifying the comment
- * to display to the user
- *
+ * @param purpose a <code>String</code> specifying the comment
+ * to display to the user
* @see #getComment
- *
*/
-
public void setComment(String purpose) {
- comment = purpose;
+ comment = purpose;
}
-
-
-
/**
* Returns the comment describing the purpose of this cookie, or
* <code>null</code> if the cookie has no comment.
*
- * @return a <code>String</code> containing the comment,
- * or <code>null</code> if none
- *
+ * @return a <code>String</code> containing the comment,
+ * or <code>null</code> if none
* @see #setComment
- *
- */
-
+ */
public String getComment() {
- return comment;
+ return comment;
}
-
-
-
-
/**
- *
* Specifies the domain within which this cookie should be presented.
- *
+ * <p/>
* <p>The form of the domain name is specified by RFC 2109. A domain
* name begins with a dot (<code>.foo.com</code>) and means that
* the cookie is visible to servers in a specified Domain Name System
- * (DNS) zone (for example, <code>www.foo.com</code>, but not
+ * (DNS) zone (for example, <code>www.foo.com</code>, but not
* <code>a.b.foo.com</code>). By default, cookies are only returned
* to the server that sent them.
*
- *
- * @param pattern a <code>String</code> containing the domain name
- * within which this cookie is visible;
- * form is according to RFC 2109
- *
+ * @param pattern a <code>String</code> containing the domain name
+ * within which this cookie is visible;
+ * form is according to RFC 2109
* @see #getDomain
- *
*/
-
public void setDomain(String pattern) {
- domain = pattern.toLowerCase(); // IE allegedly needs this
+ domain = pattern.toLowerCase(); // IE allegedly needs this
}
-
-
-
-
/**
- * Returns the domain name set for this cookie. The form of
+ * Returns the domain name set for this cookie. The form of
* the domain name is set by RFC 2109.
*
- * @return a <code>String</code> containing the domain name
- *
+ * @return a <code>String</code> containing the domain name
* @see #setDomain
- *
- */
-
+ */
public String getDomain() {
- return domain;
+ return domain;
}
-
-
-
/**
* Sets the maximum age of the cookie in seconds.
- *
+ * <p/>
* <p>A positive value indicates that the cookie will expire
* after that many seconds have passed. Note that the value is
* the <i>maximum</i> age when the cookie will expire, not the cookie's
* current age.
- *
+ * <p/>
* <p>A negative value means
* that the cookie is not stored persistently and will be deleted
* when the Web browser exits. A zero value causes the cookie
* to be deleted.
*
- * @param expiry an integer specifying the maximum age of the
- * cookie in seconds; if negative, means
- * the cookie is not stored; if zero, deletes
- * the cookie
- *
- *
+ * @param expiry an integer specifying the maximum age of the
+ * cookie in seconds; if negative, means
+ * the cookie is not stored; if zero, deletes
+ * the cookie
* @see #getMaxAge
- *
*/
-
public void setMaxAge(int expiry) {
- maxAge = expiry;
+ maxAge = expiry;
}
-
-
-
/**
* Returns the maximum age of the cookie, specified in seconds,
* By default, <code>-1</code> indicating the cookie will persist
* until browser shutdown.
*
- *
- * @return an integer specifying the maximum age of the
- * cookie in seconds; if negative, means
- * the cookie persists until browser shutdown
- *
- *
+ * @return an integer specifying the maximum age of the
+ * cookie in seconds; if negative, means
+ * the cookie persists until browser shutdown
* @see #setMaxAge
- *
*/
-
public int getMaxAge() {
- return maxAge;
+ return maxAge;
}
-
-
-
/**
* Specifies a path for the cookie
* to which the client should return the cookie.
- *
+ * <p/>
* <p>The cookie is visible to all the pages in the directory
- * you specify, and all the pages in that directory's subdirectories.
+ * you specify, and all the pages in that directory's subdirectories.
* A cookie's path must include the servlet that set the cookie,
* for example, <i>/catalog</i>, which makes the cookie
* visible to all directories on the server under <i>/catalog</i>.
- *
+ * <p/>
* <p>Consult RFC 2109 (available on the Internet) for more
* information on setting path names for cookies.
*
- *
- * @param uri a <code>String</code> specifying a path
- *
- *
+ * @param uri a <code>String</code> specifying a path
* @see #getPath
- *
*/
-
public void setPath(String uri) {
- path = uri;
+ path = uri;
}
-
-
-
/**
- * Returns the path on the server
+ * Returns the path on the server
* to which the browser returns this cookie. The
* cookie is visible to all subpaths on the server.
*
- *
- * @return a <code>String</code> specifying a path that contains
- * a servlet name, for example, <i>/catalog</i>
- *
+ * @return a <code>String</code> specifying a path that contains
+ * a servlet name, for example, <i>/catalog</i>
* @see #setPath
- *
- */
-
+ */
public String getPath() {
- return path;
+ return path;
}
-
-
-
-
/**
* Indicates to the browser whether the cookie should only be sent
* using a secure protocol, such as HTTPS or SSL.
- *
+ * <p/>
* <p>The default value is <code>false</code>.
*
- * @param flag if <code>true</code>, sends the cookie from the browser
- * to the server only when using a secure protocol;
- * if <code>false</code>, sent on any protocol
- *
+ * @param flag if <code>true</code>, sends the cookie from the browser
+ * to the server only when using a secure protocol;
+ * if <code>false</code>, sent on any protocol
* @see #getSecure
- *
*/
-
public void setSecure(boolean flag) {
- secure = flag;
+ secure = flag;
}
-
-
-
/**
* Returns <code>true</code> if the browser is sending cookies
* only over a secure protocol, or <code>false</code> if the
* browser can send cookies using any protocol.
*
- * @return <code>true</code> if the browser uses a secure protocol;
- * otherwise, <code>true</code>
- *
+ * @return <code>true</code> if the browser uses a secure protocol;
+ * otherwise, <code>true</code>
* @see #setSecure
- *
*/
-
public boolean getSecure() {
- return secure;
+ return secure;
}
-
-
-
-
/**
* Returns the name of the cookie. The name cannot be changed after
* creation.
*
- * @return a <code>String</code> specifying the cookie's name
- *
+ * @return a <code>String</code> specifying the cookie's name
*/
-
public String getName() {
- return name;
+ return name;
}
-
-
-
-
/**
- *
* Assigns a new value to a cookie after the cookie is created.
* If you use a binary value, you may want to use BASE64 encoding.
- *
- * <p>With Version 0 cookies, values should not contain white
+ * <p/>
+ * <p>With Version 0 cookies, values should not contain white
* space, brackets, parentheses, equals signs, commas,
* double quotes, slashes, question marks, at signs, colons,
* and semicolons. Empty values may not behave the same way
* on all browsers.
*
- * @param newValue a <code>String</code> specifying the new value
- *
- *
+ * @param newValue a <code>String</code> specifying the new value
* @see #getValue
* @see Cookie
- *
*/
-
public void setValue(String newValue) {
- value = newValue;
+ value = newValue;
}
-
-
-
/**
* Returns the value of the cookie.
*
- * @return a <code>String</code> containing the cookie's
- * present value
- *
+ * @return a <code>String</code> containing the cookie's
+ * present value
* @see #setValue
* @see Cookie
- *
*/
-
public String getValue() {
- return value;
+ return value;
}
-
-
-
/**
- * Returns the version of the protocol this cookie complies
- * with. Version 1 complies with RFC 2109,
+ * Returns the version of the protocol this cookie complies
+ * with. Version 1 complies with RFC 2109,
* and version 0 complies with the original
* cookie specification drafted by Netscape. Cookies provided
* by a browser use and identify the browser's cookie version.
- *
- *
- * @return 0 if the cookie complies with the
- * original Netscape specification; 1
- * if the cookie complies with RFC 2109
*
+ * @return 0 if the cookie complies with the
+ * original Netscape specification; 1
+ * if the cookie complies with RFC 2109
* @see #setVersion
- *
*/
-
public int getVersion() {
- return version;
+ return version;
}
-
-
-
/**
* Sets the version of the cookie protocol this cookie complies
* with. Version 0 complies with the original Netscape cookie
* specification. Version 1 complies with RFC 2109.
- *
+ * <p/>
* <p>Since RFC 2109 is still somewhat new, consider
* version 1 as experimental; do not use it yet on production sites.
*
- *
- * @param v 0 if the cookie should comply with
- * the original Netscape specification;
- * 1 if the cookie should comply with RFC 2109
- *
+ * @param v 0 if the cookie should comply with
+ * the original Netscape specification;
+ * 1 if the cookie should comply with RFC 2109
* @see #getVersion
- *
*/
-
public void setVersion(int v) {
- version = v;
+ version = v;
}
- // Note -- disabled for now to allow full Netscape compatibility
- // from RFC 2068, token special case characters
- //
- // private static final String tspecials = "()<>@,;:\\\"/[]?={} \t";
-
- private static final String tspecials = ",; ";
-
-
-
-
/*
* Tests a string and returns true if the string counts as a
* reserved token in the Java language.
@@ -503,42 +382,31 @@
* a reserved token; <code>false</code>
* if it is not
*/
-
private boolean isToken(String value) {
- int len = value.length();
+ int len = value.length();
- for (int i = 0; i < len; i++) {
- char c = value.charAt(i);
+ for (int i = 0; i < len; i++) {
+ char c = value.charAt(i);
- if (c < 0x20 || c >= 0x7f || tspecials.indexOf(c) != -1)
- return false;
- }
- return true;
+ if (c < 0x20 || c >= 0x7f || tspecials.indexOf(c) != -1)
+ return false;
+ }
+ return true;
}
-
-
-
-
-
/**
- *
- * Overrides the standard <code>java.lang.Object.clone</code>
+ * Overrides the standard <code>java.lang.Object.clone</code>
* method to return a copy of this cookie.
- *
- *
*/
-
public Object clone() {
- try {
- return super.clone();
- } catch (CloneNotSupportedException e) {
- throw new RuntimeException(e.getMessage());
- }
+ try {
+ return super.clone();
+ } catch (CloneNotSupportedException e) {
+ throw new RuntimeException(e.getMessage());
+ }
}
/**
- *
* @return whether cookie is http only
* @since servlet 3.0
*/
@@ -547,7 +415,6 @@
}
/**
- *
* @param httpOnly httpOnly setting
* @since servlet 3.0
*/
Modified: geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/http/HttpServlet.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/http/HttpServlet.java?rev=788194&r1=788193&r2=788194&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/http/HttpServlet.java (original)
+++ geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/http/HttpServlet.java Wed Jun 24 22:05:48 2009
@@ -37,54 +37,48 @@
/**
- *
* Provides an abstract class to be subclassed to create
* an HTTP servlet suitable for a Web site. A subclass of
- * <code>HttpServlet</code> must override at least
+ * <code>HttpServlet</code> must override at least
* one method, usually one of these:
- *
+ * <p/>
* <ul>
* <li> <code>doGet</code>, if the servlet supports HTTP GET requests
* <li> <code>doPost</code>, for HTTP POST requests
* <li> <code>doPut</code>, for HTTP PUT requests
* <li> <code>doDelete</code>, for HTTP DELETE requests
- * <li> <code>init</code> and <code>destroy</code>,
+ * <li> <code>init</code> and <code>destroy</code>,
* to manage resources that are held for the life of the servlet
* <li> <code>getServletInfo</code>, which the servlet uses to
- * provide information about itself
+ * provide information about itself
* </ul>
- *
+ * <p/>
* <p>There's almost no reason to override the <code>service</code>
* method. <code>service</code> handles standard HTTP
* requests by dispatching them to the handler methods
* for each HTTP request type (the <code>do</code><i>XXX</i>
* methods listed above).
- *
- * <p>Likewise, there's almost no reason to override the
+ * <p/>
+ * <p>Likewise, there's almost no reason to override the
* <code>doOptions</code> and <code>doTrace</code> methods.
- *
+ * <p/>
* <p>Servlets typically run on multithreaded servers,
* so be aware that a servlet must handle concurrent
* requests and be careful to synchronize access to shared resources.
* Shared resources include in-memory data such as
* instance or class variables and external objects
- * such as files, database connections, and network
+ * such as files, database connections, and network
* connections.
* See the
* <a href="http://java.sun.com/Series/Tutorial/java/threads/multithreaded.html">
* Java Tutorial on Multithreaded Programming</a> for more
* information on handling multiple threads in a Java program.
*
- * @author Various
- * @version $Version$
- *
+ * @version $Rev$ $Date$
*/
-
-
public abstract class HttpServlet extends GenericServlet
- implements java.io.Serializable
-{
+ implements java.io.Serializable {
private static final String METHOD_DELETE = "DELETE";
private static final String METHOD_HEAD = "HEAD";
private static final String METHOD_GET = "GET";
@@ -95,144 +89,115 @@
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";
+ "javax.servlet.http.LocalStrings";
private static ResourceBundle lStrings =
- ResourceBundle.getBundle(LSTRING_FILE);
-
-
-
-
+ ResourceBundle.getBundle(LSTRING_FILE);
+
/**
* Does nothing, because this is an abstract class.
- *
*/
- public HttpServlet() { }
-
-
+ public HttpServlet() {
+ }
/**
- *
* Called by the server (via the <code>service</code> method) to
- * allow a servlet to handle a GET request.
- *
+ * allow a servlet to handle a GET request.
+ * <p/>
* <p>Overriding this method to support a GET request also
* automatically supports an HTTP HEAD request. A HEAD
* request is a GET request that returns no body in the
* response, only the request header fields.
- *
+ * <p/>
* <p>When overriding this method, read the request data,
- * write the response headers, get the response's writer or
+ * write the response headers, get the response's writer or
* output stream object, and finally, write the response data.
* It's best to include content type and encoding. When using
* a <code>PrintWriter</code> object to return the response,
* set the content type before accessing the
* <code>PrintWriter</code> object.
- *
+ * <p/>
* <p>The servlet container must write the headers before
* committing the response, because in HTTP the headers must be sent
* before the response body.
- *
+ * <p/>
* <p>Where possible, set the Content-Length header (with the
* {@link javax.servlet.ServletResponse#setContentLength} method),
- * to allow the servlet container to use a persistent connection
+ * to allow the servlet container to use a persistent connection
* to return its response to the client, improving performance.
* The content length is automatically set if the entire response fits
* inside the response buffer.
- *
+ * <p/>
* <p>When using HTTP 1.1 chunked encoding (which means that the response
* has a Transfer-Encoding header), do not set the Content-Length header.
- *
+ * <p/>
* <p>The GET method should be safe, that is, without
* any side effects for which users are held responsible.
* For example, most form queries have no side effects.
* If a client request is intended to change stored data,
* the request should use some other HTTP method.
- *
+ * <p/>
* <p>The GET method should also be idempotent, meaning
* that it can be safely repeated. Sometimes making a
- * method safe also makes it idempotent. For example,
+ * method safe also makes it idempotent. For example,
* repeating queries is both safe and idempotent, but
* buying a product online or modifying data is neither
- * safe nor idempotent.
- *
+ * safe nor idempotent.
+ * <p/>
* <p>If the request is incorrectly formatted, <code>doGet</code>
* returns an HTTP "Bad Request" message.
- *
- *
- * @param req an {@link HttpServletRequest} object that
- * contains the request the client has made
- * of the servlet
- *
- * @param resp an {@link HttpServletResponse} object that
- * contains the response the servlet sends
- * to the client
- *
- * @exception IOException if an input or output error is
- * detected when the servlet handles
- * the GET request
- *
- * @exception ServletException if the request for the GET
- * could not be handled
*
- *
+ * @param req an {@link HttpServletRequest} object that
+ * contains the request the client has made
+ * of the servlet
+ * @param resp an {@link HttpServletResponse} object that
+ * contains the response the servlet sends
+ * to the client
+ * @throws IOException if an input or output error is
+ * detected when the servlet handles
+ * the GET request
+ * @throws ServletException if the request for the GET
+ * could not be handled
* @see javax.servlet.ServletResponse#setContentType
- *
*/
-
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(HttpServletResponse.SC_METHOD_NOT_ALLOWED, msg);
- } else {
- resp.sendError(HttpServletResponse.SC_BAD_REQUEST, msg);
- }
+ throws ServletException, IOException {
+ String protocol = req.getProtocol();
+ String msg = lStrings.getString("http.method_get_not_supported");
+ if (protocol.endsWith("1.1")) {
+ resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, msg);
+ } else {
+ resp.sendError(HttpServletResponse.SC_BAD_REQUEST, msg);
+ }
}
-
-
-
-
/**
- *
* Returns the time the <code>HttpServletRequest</code>
* object was last modified,
* in milliseconds since midnight January 1, 1970 GMT.
* If the time is unknown, this method returns a negative
* number (the default).
- *
+ * <p/>
* <p>Servlets that support HTTP GET requests and can quickly determine
* their last modification time should override this method.
* This makes browser and proxy caches work more effectively,
* reducing the load on server and network resources.
*
- *
- * @param req the <code>HttpServletRequest</code>
- * object that is sent to the servlet
- *
- * @return a <code>long</code> integer specifying
- * the time the <code>HttpServletRequest</code>
- * object was last modified, in milliseconds
- * since midnight, January 1, 1970 GMT, or
- * -1 if the time is not known
- *
+ * @param req the <code>HttpServletRequest</code>
+ * object that is sent to the servlet
+ * @return a <code>long</code> integer specifying
+ * the time the <code>HttpServletRequest</code>
+ * object was last modified, in milliseconds
+ * since midnight, January 1, 1970 GMT, or
+ * -1 if the time is not known
*/
-
protected long getLastModified(HttpServletRequest req) {
- return -1;
+ return -1;
}
-
-
-
/**
- *
- *
* <p>Receives an HTTP HEAD request from the protected
* <code>service</code> method and handles the
* request.
@@ -241,129 +206,105 @@
* Content-Type or Content-Length. The HTTP HEAD
* method counts the output bytes in the response
* to set the Content-Length header accurately.
- *
+ * <p/>
* <p>If you override this method, you can avoid computing
* the response body and just set the response headers
* directly to improve performance. Make sure that the
* <code>doHead</code> method you write is both safe
* and idempotent (that is, protects itself from being
* called multiple times for one HTTP HEAD request).
- *
+ * <p/>
* <p>If the HTTP HEAD request is incorrectly formatted,
* <code>doHead</code> returns an HTTP "Bad Request"
* message.
*
- *
- * @param req the request object that is passed
- * to the servlet
- *
- * @param resp the response object that the servlet
- * uses to return the headers to the clien
- *
- * @exception IOException if an input or output error occurs
- *
- * @exception ServletException if the request for the HEAD
- * could not be handled
+ * @param req the request object that is passed
+ * to the servlet
+ * @param resp the response object that the servlet
+ * uses to return the headers to the clien
+ * @throws IOException if an input or output error occurs
+ * @throws ServletException if the request for the HEAD
+ * could not be handled
*/
-
protected void doHead(HttpServletRequest req, HttpServletResponse resp)
- throws ServletException, IOException
- {
- NoBodyResponse response = new NoBodyResponse(resp);
-
- doGet(req, response);
- response.setContentLength();
- }
-
-
-
+ throws ServletException, IOException {
+ NoBodyResponse response = new NoBodyResponse(resp);
+ doGet(req, response);
+ response.setContentLength();
+ }
/**
- *
* Called by the server (via the <code>service</code> method)
* to allow a servlet to handle a POST request.
- *
+ * <p/>
* The HTTP POST method allows the client to send
* data of unlimited length to the Web server a single time
* and is useful when posting information such as
* credit card numbers.
- *
+ * <p/>
* <p>When overriding this method, read the request data,
* write the response headers, get the response's writer or output
- * stream object, and finally, write the response data. It's best
+ * stream object, and finally, write the response data. It's best
* to include content type and encoding. When using a
- * <code>PrintWriter</code> object to return the response, set the
- * content type before accessing the <code>PrintWriter</code> object.
- *
+ * <code>PrintWriter</code> object to return the response, set the
+ * content type before accessing the <code>PrintWriter</code> object.
+ * <p/>
* <p>The servlet container must write the headers before committing the
- * response, because in HTTP the headers must be sent before the
+ * response, because in HTTP the headers must be sent before the
* response body.
- *
+ * <p/>
* <p>Where possible, set the Content-Length header (with the
* {@link javax.servlet.ServletResponse#setContentLength} method),
- * to allow the servlet container to use a persistent connection
+ * to allow the servlet container to use a persistent connection
* to return its response to the client, improving performance.
* The content length is automatically set if the entire response fits
- * inside the response buffer.
- *
+ * inside the response buffer.
+ * <p/>
* <p>When using HTTP 1.1 chunked encoding (which means that the response
- * has a Transfer-Encoding header), do not set the Content-Length header.
- *
+ * has a Transfer-Encoding header), do not set the Content-Length header.
+ * <p/>
* <p>This method does not need to be either safe or idempotent.
* Operations requested through POST can have side effects for
- * which the user can be held accountable, for example,
+ * which the user can be held accountable, for example,
* updating stored data or buying items online.
- *
+ * <p/>
* <p>If the HTTP POST request is incorrectly formatted,
* <code>doPost</code> returns an HTTP "Bad Request" message.
*
- *
- * @param req an {@link HttpServletRequest} object that
- * contains the request the client has made
- * of the servlet
- *
- * @param resp an {@link HttpServletResponse} object that
- * contains the response the servlet sends
- * to the client
- *
- * @exception IOException if an input or output error is
- * detected when the servlet handles
- * the request
- *
- * @exception ServletException if the request for the POST
- * could not be handled
- *
- *
+ * @param req an {@link HttpServletRequest} object that
+ * contains the request the client has made
+ * of the servlet
+ * @param resp an {@link HttpServletResponse} object that
+ * contains the response the servlet sends
+ * to the client
+ * @throws IOException if an input or output error is
+ * detected when the servlet handles
+ * the request
+ * @throws ServletException if the request for the POST
+ * could not be handled
* @see javax.servlet.ServletOutputStream
* @see javax.servlet.ServletResponse#setContentType
- *
- *
*/
-
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(HttpServletResponse.SC_METHOD_NOT_ALLOWED, msg);
- } else {
- resp.sendError(HttpServletResponse.SC_BAD_REQUEST, msg);
- }
+ throws ServletException, IOException {
+ String protocol = req.getProtocol();
+ String msg = lStrings.getString("http.method_post_not_supported");
+ if (protocol.endsWith("1.1")) {
+ resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, msg);
+ } else {
+ resp.sendError(HttpServletResponse.SC_BAD_REQUEST, msg);
+ }
}
-
-
-
/**
* Called by the server (via the <code>service</code> method)
* to allow a servlet to handle a PUT request.
- *
- * The PUT operation allows a client to
- * place a file on the server and is similar to
+ * <p/>
+ * The PUT operation allows a client to
+ * place a file on the server and is similar to
* sending a file by FTP.
- *
+ * <p/>
* <p>When overriding this method, leave intact
* any content headers sent with the request (including
* Content-Length, Content-Type, Content-Transfer-Encoding,
@@ -373,101 +314,80 @@
* (HTTP 501 - Not Implemented) and discard the request.
* For more information on HTTP 1.1, see RFC 2616
* <a href="http://www.ietf.org/rfc/rfc2616.txt"></a>.
- *
+ * <p/>
* <p>This method does not need to be either safe or idempotent.
* Operations that <code>doPut</code> performs can have side
* effects for which the user can be held accountable. When using
* this method, it may be useful to save a copy of the
* affected URL in temporary storage.
- *
+ * <p/>
* <p>If the HTTP PUT request is incorrectly formatted,
* <code>doPut</code> returns an HTTP "Bad Request" message.
*
- *
- * @param req the {@link HttpServletRequest} object that
- * contains the request the client made of
- * the servlet
- *
- * @param resp the {@link HttpServletResponse} object that
- * contains the response the servlet returns
- * to the client
- *
- * @exception IOException if an input or output error occurs
- * while the servlet is handling the
- * PUT request
- *
- * @exception ServletException if the request for the PUT
- * cannot be handled
- *
+ * @param req the {@link HttpServletRequest} object that
+ * contains the request the client made of
+ * the servlet
+ * @param resp the {@link HttpServletResponse} object that
+ * contains the response the servlet returns
+ * to the client
+ * @throws IOException if an input or output error occurs
+ * while the servlet is handling the
+ * PUT request
+ * @throws ServletException if the request for the PUT
+ * cannot be handled
*/
-
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(HttpServletResponse.SC_METHOD_NOT_ALLOWED, msg);
- } else {
- resp.sendError(HttpServletResponse.SC_BAD_REQUEST, msg);
- }
+ throws ServletException, IOException {
+ String protocol = req.getProtocol();
+ String msg = lStrings.getString("http.method_put_not_supported");
+ if (protocol.endsWith("1.1")) {
+ resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, msg);
+ } else {
+ resp.sendError(HttpServletResponse.SC_BAD_REQUEST, msg);
+ }
}
-
-
-
/**
- *
* Called by the server (via the <code>service</code> method)
* to allow a servlet to handle a DELETE request.
- *
+ * <p/>
* The DELETE operation allows a client to remove a document
* or Web page from the server.
- *
+ * <p/>
* <p>This method does not need to be either safe
* or idempotent. Operations requested through
* DELETE can have side effects for which users
* can be held accountable. When using
* this method, it may be useful to save a copy of the
* affected URL in temporary storage.
- *
+ * <p/>
* <p>If the HTTP DELETE request is incorrectly formatted,
* <code>doDelete</code> returns an HTTP "Bad Request"
* message.
*
- *
- * @param req the {@link HttpServletRequest} object that
- * contains the request the client made of
- * the servlet
- *
- *
- * @param resp the {@link HttpServletResponse} object that
- * contains the response the servlet returns
- * to the client
- *
- *
- * @exception IOException if an input or output error occurs
- * while the servlet is handling the
- * DELETE request
- *
- * @exception ServletException if the request for the
- * DELETE cannot be handled
- *
+ * @param req the {@link HttpServletRequest} object that
+ * contains the request the client made of
+ * the servlet
+ * @param resp the {@link HttpServletResponse} object that
+ * contains the response the servlet returns
+ * to the client
+ * @throws IOException if an input or output error occurs
+ * while the servlet is handling the
+ * DELETE request
+ * @throws ServletException if the request for the
+ * DELETE cannot be handled
*/
-
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(HttpServletResponse.SC_METHOD_NOT_ALLOWED, msg);
- } else {
- resp.sendError(HttpServletResponse.SC_BAD_REQUEST, msg);
- }
+ 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(HttpServletResponse.SC_METHOD_NOT_ALLOWED, msg);
+ } else {
+ resp.sendError(HttpServletResponse.SC_BAD_REQUEST, msg);
+ }
}
-
private static Method[] getAllDeclaredMethods(Class c) {
@@ -477,271 +397,229 @@
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);
+ 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;
- }
+ thisMethods = allMethods;
+ }
- return thisMethods;
+ return thisMethods;
}
-
/**
* Called by the server (via the <code>service</code> method)
* to allow a servlet to handle a OPTIONS request.
- *
- * The OPTIONS request determines which HTTP methods
+ * <p/>
+ * The OPTIONS request determines which HTTP methods
* the server supports and
* returns an appropriate header. For example, if a servlet
* overrides <code>doGet</code>, this method returns the
* following header:
- *
+ * <p/>
* <p><code>Allow: GET, HEAD, TRACE, OPTIONS</code>
- *
+ * <p/>
* <p>There's no need to override this method unless the
- * servlet implements new HTTP methods, beyond those
+ * servlet implements new HTTP methods, beyond those
* implemented by HTTP 1.1.
*
- * @param req the {@link HttpServletRequest} object that
- * contains the request the client made of
- * the servlet
- *
- *
- * @param resp the {@link HttpServletResponse} object that
- * contains the response the servlet returns
- * to the client
- *
- *
- * @exception IOException if an input or output error occurs
- * while the servlet is handling the
- * OPTIONS request
- *
- * @exception ServletException if the request for the
- * OPTIONS cannot be handled
- *
+ * @param req the {@link HttpServletRequest} object that
+ * contains the request the client made of
+ * the servlet
+ * @param resp the {@link HttpServletResponse} object that
+ * contains the response the servlet returns
+ * to the client
+ * @throws IOException if an input or output error occurs
+ * while the servlet is handling the
+ * OPTIONS request
+ * @throws ServletException if the request for the
+ * OPTIONS cannot be handled
*/
-
protected void doOptions(HttpServletRequest req, HttpServletResponse resp)
- throws ServletException, IOException
- {
- Method[] methods = getAllDeclaredMethods(this.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)
- if (allow==null) allow=METHOD_GET;
- if (ALLOW_HEAD)
- if (allow==null) allow=METHOD_HEAD;
- else allow += ", " + METHOD_HEAD;
- if (ALLOW_POST)
- if (allow==null) allow=METHOD_POST;
- else allow += ", " + METHOD_POST;
- if (ALLOW_PUT)
- if (allow==null) allow=METHOD_PUT;
- else allow += ", " + METHOD_PUT;
- if (ALLOW_DELETE)
- if (allow==null) allow=METHOD_DELETE;
- else allow += ", " + METHOD_DELETE;
- if (ALLOW_TRACE)
- if (allow==null) allow=METHOD_TRACE;
- else allow += ", " + METHOD_TRACE;
- if (ALLOW_OPTIONS)
- if (allow==null) allow=METHOD_OPTIONS;
- else allow += ", " + METHOD_OPTIONS;
-
- resp.setHeader("Allow", allow);
- }
-
-
-
-
+ throws ServletException, IOException {
+ Method[] methods = getAllDeclaredMethods(this.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)
+ if (allow == null) allow = METHOD_GET;
+ if (ALLOW_HEAD)
+ if (allow == null) allow = METHOD_HEAD;
+ else allow += ", " + METHOD_HEAD;
+ if (ALLOW_POST)
+ if (allow == null) allow = METHOD_POST;
+ else allow += ", " + METHOD_POST;
+ if (ALLOW_PUT)
+ if (allow == null) allow = METHOD_PUT;
+ else allow += ", " + METHOD_PUT;
+ if (ALLOW_DELETE)
+ if (allow == null) allow = METHOD_DELETE;
+ else allow += ", " + METHOD_DELETE;
+ if (ALLOW_TRACE)
+ if (allow == null) allow = METHOD_TRACE;
+ else allow += ", " + METHOD_TRACE;
+ if (ALLOW_OPTIONS)
+ if (allow == null) allow = METHOD_OPTIONS;
+ else allow += ", " + METHOD_OPTIONS;
+
+ resp.setHeader("Allow", allow);
+ }
+
/**
* Called by the server (via the <code>service</code> method)
* to allow a servlet to handle a TRACE request.
- *
+ * <p/>
* A TRACE returns the headers sent with the TRACE
* request to the client, so that they can be used in
- * debugging. There's no need to override this method.
- *
- *
- *
- * @param req the {@link HttpServletRequest} object that
- * contains the request the client made of
- * the servlet
- *
- *
- * @param resp the {@link HttpServletResponse} object that
- * contains the response the servlet returns
- * to the client
- *
- *
- * @exception IOException if an input or output error occurs
- * while the servlet is handling the
- * TRACE request
+ * debugging. There's no need to override this method.
*
- * @exception ServletException if the request for the
- * TRACE cannot be handled
- *
- */
-
- protected void doTrace(HttpServletRequest req, HttpServletResponse resp)
- throws ServletException, IOException
- {
-
- int responseLength;
-
- String CRLF = "\r\n";
- String responseString = "TRACE "+ req.getRequestURI()+
- " " + req.getProtocol();
-
- Enumeration reqHeaderEnum = req.getHeaderNames();
-
- while( reqHeaderEnum.hasMoreElements() ) {
- String headerName = (String)reqHeaderEnum.nextElement();
- responseString += CRLF + headerName + ": " +
- req.getHeader(headerName);
- }
-
- responseString += CRLF;
-
- responseLength = responseString.length();
-
- resp.setContentType("message/http");
- resp.setContentLength(responseLength);
- ServletOutputStream out = resp.getOutputStream();
- out.print(responseString);
- out.close();
- return;
- }
-
+ * @param req the {@link HttpServletRequest} object that
+ * contains the request the client made of
+ * the servlet
+ * @param resp the {@link HttpServletResponse} object that
+ * contains the response the servlet returns
+ * to the client
+ * @throws IOException if an input or output error occurs
+ * while the servlet is handling the
+ * TRACE request
+ * @throws ServletException if the request for the
+ * TRACE cannot be handled
+ */
+ protected void doTrace(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+
+ int responseLength;
+
+ String CRLF = "\r\n";
+ String responseString = "TRACE " + req.getRequestURI() +
+ " " + req.getProtocol();
+
+ Enumeration reqHeaderEnum = req.getHeaderNames();
+
+ while (reqHeaderEnum.hasMoreElements()) {
+ String headerName = (String) reqHeaderEnum.nextElement();
+ responseString += CRLF + headerName + ": " +
+ req.getHeader(headerName);
+ }
+ responseString += CRLF;
+ responseLength = responseString.length();
+ resp.setContentType("message/http");
+ resp.setContentLength(responseLength);
+ ServletOutputStream out = resp.getOutputStream();
+ out.print(responseString);
+ out.close();
+ return;
+ }
/**
- *
* Receives standard HTTP requests from the public
* <code>service</code> method and dispatches
- * them to the <code>do</code><i>XXX</i> methods defined in
- * this class. This method is an HTTP-specific version of the
+ * them to the <code>do</code><i>XXX</i> methods defined in
+ * this class. This method is an HTTP-specific version of the
* {@link javax.servlet.Servlet#service} method. There's no
* need to override this method.
*
- *
- *
- * @param req the {@link HttpServletRequest} object that
- * contains the request the client made of
- * the servlet
- *
- *
- * @param resp the {@link HttpServletResponse} object that
- * contains the response the servlet returns
- * to the client
- *
- *
- * @exception IOException if an input or output error occurs
- * while the servlet is handling the
- * HTTP request
- *
- * @exception ServletException if the HTTP request
- * cannot be handled
- *
- * @see javax.servlet.Servlet#service
- *
+ * @param req the {@link HttpServletRequest} object that
+ * contains the request the client made of
+ * the servlet
+ * @param resp the {@link HttpServletResponse} object that
+ * contains the response the servlet returns
+ * to the client
+ * @throws IOException if an input or output error occurs
+ * while the servlet is handling the
+ * HTTP request
+ * @throws ServletException if the HTTP request
+ * cannot be handled
+ * @see javax.servlet.Servlet#service
*/
-
protected void service(HttpServletRequest req, HttpServletResponse resp)
- throws ServletException, IOException
- {
- String method = req.getMethod();
-
- if (method.equals(METHOD_GET)) {
- long lastModified = getLastModified(req);
- if (lastModified == -1) {
- // servlet doesn't support if-modified-since, no reason
- // to go through further expensive logic
- doGet(req, resp);
- } else {
- long ifModifiedSince = req.getDateHeader(HEADER_IFMODSINCE);
- if (ifModifiedSince < (lastModified / 1000 * 1000)) {
- // If the servlet mod time is later, call doGet()
+ throws ServletException, IOException {
+ String method = req.getMethod();
+
+ if (method.equals(METHOD_GET)) {
+ long lastModified = getLastModified(req);
+ if (lastModified == -1) {
+ // servlet doesn't support if-modified-since, no reason
+ // to go through further expensive logic
+ doGet(req, resp);
+ } else {
+ long ifModifiedSince = req.getDateHeader(HEADER_IFMODSINCE);
+ if (ifModifiedSince < (lastModified / 1000 * 1000)) {
+ // If the servlet mod time is later, call doGet()
// Round down to the nearest second for a proper compare
// A ifModifiedSince of -1 will always be less
- maybeSetLastModified(resp, lastModified);
- doGet(req, resp);
- } else {
- resp.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
- }
- }
-
- } else if (method.equals(METHOD_HEAD)) {
- long lastModified = getLastModified(req);
- maybeSetLastModified(resp, lastModified);
- doHead(req, resp);
-
- } else if (method.equals(METHOD_POST)) {
- doPost(req, resp);
-
- } else if (method.equals(METHOD_PUT)) {
- doPut(req, resp);
-
- } else if (method.equals(METHOD_DELETE)) {
- doDelete(req, resp);
-
- } else if (method.equals(METHOD_OPTIONS)) {
- doOptions(req,resp);
-
- } else if (method.equals(METHOD_TRACE)) {
- doTrace(req,resp);
-
- } else {
- //
- // Note that this means NO servlet supports whatever
- // method was requested, anywhere on this server.
- //
-
- String errMsg = lStrings.getString("http.method_not_implemented");
- Object[] errArgs = new Object[1];
- errArgs[0] = method;
- errMsg = MessageFormat.format(errMsg, errArgs);
-
- resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, errMsg);
- }
- }
-
-
-
+ maybeSetLastModified(resp, lastModified);
+ doGet(req, resp);
+ } else {
+ resp.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
+ }
+ }
+
+ } else if (method.equals(METHOD_HEAD)) {
+ long lastModified = getLastModified(req);
+ maybeSetLastModified(resp, lastModified);
+ doHead(req, resp);
+
+ } else if (method.equals(METHOD_POST)) {
+ doPost(req, resp);
+
+ } else if (method.equals(METHOD_PUT)) {
+ doPut(req, resp);
+
+ } else if (method.equals(METHOD_DELETE)) {
+ doDelete(req, resp);
+
+ } else if (method.equals(METHOD_OPTIONS)) {
+ doOptions(req, resp);
+
+ } else if (method.equals(METHOD_TRACE)) {
+ doTrace(req, resp);
+
+ } else {
+ //
+ // Note that this means NO servlet supports whatever
+ // method was requested, anywhere on this server.
+ //
+
+ String errMsg = lStrings.getString("http.method_not_implemented");
+ Object[] errArgs = new Object[1];
+ errArgs[0] = method;
+ errMsg = MessageFormat.format(errMsg, errArgs);
+ resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, errMsg);
+ }
+ }
/*
* Sets the Last-Modified entity header field, if it has not
@@ -750,157 +628,132 @@
* written. A subclass might have set this header already, so we
* check.
*/
-
private void maybeSetLastModified(HttpServletResponse resp,
- long lastModified) {
- if (resp.containsHeader(HEADER_LASTMOD))
- return;
- if (lastModified >= 0)
- resp.setDateHeader(HEADER_LASTMOD, lastModified);
- }
-
-
-
-
+ long lastModified) {
+ if (resp.containsHeader(HEADER_LASTMOD))
+ return;
+ if (lastModified >= 0)
+ resp.setDateHeader(HEADER_LASTMOD, lastModified);
+ }
+
/**
- *
* Dispatches client requests to the protected
* <code>service</code> method. There's no need to
* override this method.
*
- *
- * @param req the {@link HttpServletRequest} object that
- * contains the request the client made of
- * the servlet
- *
- *
- * @param res the {@link HttpServletResponse} object that
- * contains the response the servlet returns
- * to the client
- *
- *
- * @exception IOException if an input or output error occurs
- * while the servlet is handling the
- * HTTP request
- *
- * @exception ServletException if the HTTP request cannot
- * be handled
- *
- *
+ * @param req the {@link HttpServletRequest} object that
+ * contains the request the client made of
+ * the servlet
+ * @param res the {@link HttpServletResponse} object that
+ * contains the response the servlet returns
+ * to the client
+ * @throws IOException if an input or output error occurs
+ * while the servlet is handling the
+ * HTTP request
+ * @throws ServletException if the HTTP request cannot
+ * be handled
* @see javax.servlet.Servlet#service
- *
*/
-
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);
+ 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);
}
}
-
-
-
/*
* A response that includes no body, for use in (dumb) "HEAD" support.
* This just swallows that body, counting the bytes in order to set
* the content length appropriately. All other methods delegate directly
* to the HTTP Servlet Response object used to construct this one.
*/
+
// file private
class NoBodyResponse extends HttpServletResponseWrapper {
- private NoBodyOutputStream noBody;
- private PrintWriter writer;
- private boolean didSetContentLength;
+ private NoBodyOutputStream noBody;
+ private PrintWriter writer;
+ private boolean didSetContentLength;
// file private
NoBodyResponse(HttpServletResponse r) {
super(r);
- noBody = new NoBodyOutputStream();
+ noBody = new NoBodyOutputStream();
}
// file private
void setContentLength() {
- if (!didSetContentLength)
- super.setContentLength(noBody.getContentLength());
+ if (!didSetContentLength)
+ super.setContentLength(noBody.getContentLength());
}
-
// SERVLET RESPONSE interface methods
public void setContentLength(int len) {
- super.setContentLength(len);
- didSetContentLength = true;
+ super.setContentLength(len);
+ didSetContentLength = true;
}
- public ServletOutputStream getOutputStream() throws IOException
- { return noBody; }
-
- public PrintWriter getWriter() throws UnsupportedEncodingException
- {
- if (writer == null) {
- OutputStreamWriter w;
-
- w = new OutputStreamWriter(noBody, getCharacterEncoding());
- writer = new PrintWriter(w);
- }
- return writer;
+ public ServletOutputStream getOutputStream() throws IOException {
+ return noBody;
}
-}
-
-
-
-
+ public PrintWriter getWriter() throws UnsupportedEncodingException {
+ if (writer == null) {
+ OutputStreamWriter w;
+ w = new OutputStreamWriter(noBody, getCharacterEncoding());
+ writer = new PrintWriter(w);
+ }
+ return writer;
+ }
+}
/*
* Servlet output stream that gobbles up all its data.
*/
-
+
// file private
class NoBodyOutputStream extends ServletOutputStream {
private static final String LSTRING_FILE =
- "javax.servlet.http.LocalStrings";
+ "javax.servlet.http.LocalStrings";
private static ResourceBundle lStrings =
- ResourceBundle.getBundle(LSTRING_FILE);
+ ResourceBundle.getBundle(LSTRING_FILE);
- private int contentLength = 0;
+ private int contentLength = 0;
// file private
- NoBodyOutputStream() {}
+ NoBodyOutputStream() {
+ }
// file private
int getContentLength() {
- return contentLength;
+ return contentLength;
}
public void write(int b) {
- contentLength++;
+ contentLength++;
}
public void write(byte buf[], int offset, int len)
- throws IOException
- {
- if (len >= 0) {
- contentLength += len;
- } else {
- // XXX
- // isn't this really an IllegalArgumentException?
-
- String msg = lStrings.getString("err.io.negativelength");
- throw new IOException("negative length");
- }
+ throws IOException {
+ if (len >= 0) {
+ contentLength += len;
+ } else {
+ // XXX
+ // isn't this really an IllegalArgumentException?
+
+ String msg = lStrings.getString("err.io.negativelength");
+ throw new IOException("negative length");
+ }
}
}