JBossWeb SVN: r1019 - in trunk/test: webapps/cookies and 1 other directory.
by jbossweb-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2009-04-20 05:49:53 -0400 (Mon, 20 Apr 2009)
New Revision: 1019
Modified:
trunk/test/java/org/jboss/web/cookies/CookiesTestCase.java
trunk/test/webapps/cookies/test.jsp
Log:
Add a test for bugzilla ASF 45272.
Modified: trunk/test/java/org/jboss/web/cookies/CookiesTestCase.java
===================================================================
--- trunk/test/java/org/jboss/web/cookies/CookiesTestCase.java 2009-04-19 17:37:46 UTC (rev 1018)
+++ trunk/test/java/org/jboss/web/cookies/CookiesTestCase.java 2009-04-20 09:49:53 UTC (rev 1019)
@@ -136,7 +136,18 @@
public void testTestW39() { writeTest(39); }
public void testTestW40() { writeTest(40); }
+ // Bugzilla 45272
+ public void testTestW41() { writeTest(41, "a", "Path=/"); }
+ public void testTestW42() { writeTest(42, "a", "Version=1; Path=/"); }
+
+
+ // Store the received cookies.
+ private String cookies [] = null;
+
public void writeTest(int test) {
+ writeTest(test, null, null);
+ }
+ public void writeTest(int test, String name, String token) {
try {
String result = Mytest(test, null, false);
if (result != null)
@@ -144,7 +155,22 @@
} catch (Exception ex) {
ex.printStackTrace();
fail("Test failed because of " + ex);
+ return;
}
+ /* Tests the cookies */
+ if (name == null)
+ return; // nothing to do...
+ if (cookies != null) {
+ String sname = name + "=";
+ for (int i=0; i<cookies.length; i++) {
+ if (cookies[i].startsWith(sname)) {
+ if (cookies[i].indexOf(token)==-1) {
+ fail("Can't find token in " + cookies[i]);
+ return;
+ }
+ }
+ }
+ }
}
public void readTest(int test, String cookie) {
@@ -186,6 +212,7 @@
String header = reader.readLine();
int contentLength = 0;
String error = "Unknown";
+ cookies = null;
while (!"".equals(header)) {
int colon = header.indexOf(':');
String headerName = header.substring(0, colon).trim();
@@ -196,6 +223,19 @@
if ("ERROR".equalsIgnoreCase(headerName)) {
error = headerValue;
}
+ if ("set-cookie".equalsIgnoreCase(headerName)) {
+ if (cookies == null) {
+ cookies = new String [1];
+ cookies[0] = headerValue;
+ } else {
+ String [] oldcookies = cookies;
+ cookies = new String [oldcookies.length + 1];
+ for (int i=0; i<oldcookies.length; i++) {
+ cookies[i] = oldcookies[i];
+ }
+ cookies[oldcookies.length] = headerValue;
+ }
+ }
header = reader.readLine();
}
if (contentLength > 0) {
Modified: trunk/test/webapps/cookies/test.jsp
===================================================================
--- trunk/test/webapps/cookies/test.jsp 2009-04-19 17:37:46 UTC (rev 1018)
+++ trunk/test/webapps/cookies/test.jsp 2009-04-20 09:49:53 UTC (rev 1019)
@@ -92,6 +92,10 @@
case 38: test(response, out, "a", "=:", "foo", "b=:ar"); break;
case 39: test(response, out, "a", ":", "foo", "b:ar"); break;
case 40: test(response, out, "a", "=", "foo", "b=ar"); break;
+
+ case 41: test(response, out, "/", 0); break;
+ case 42: test(response, out, "/", 1); break;
+
default: sendError(response, "Unknown test");break;
}
} else {
@@ -193,4 +197,11 @@
cookie = new Cookie(name2, val2);
response.addCookie(cookie);
out.println("OK");
+ }
+void test(HttpServletResponse response, JspWriter out, String path, int version) throws Exception {
+ Cookie cookie = new Cookie("a", "b");
+ cookie.setVersion(version);
+ cookie.setPath(path);
+ response.addCookie(cookie);
+ out.println("OK");
}%>
15 years
JBossWeb SVN: r1018 - trunk/java/org/apache/catalina/connector.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-04-19 13:37:46 -0400 (Sun, 19 Apr 2009)
New Revision: 1018
Modified:
trunk/java/org/apache/catalina/connector/LocalStrings.properties
trunk/java/org/apache/catalina/connector/Request.java
Log:
- Fix Part type (the spec implies using a map anyway).
Modified: trunk/java/org/apache/catalina/connector/LocalStrings.properties
===================================================================
--- trunk/java/org/apache/catalina/connector/LocalStrings.properties 2009-04-19 17:17:15 UTC (rev 1017)
+++ trunk/java/org/apache/catalina/connector/LocalStrings.properties 2009-04-19 17:37:46 UTC (rev 1018)
@@ -47,6 +47,7 @@
coyoteRequest.listenerStart=Exception sending context initialized event to listener instance of class {0}
coyoteRequest.listenerStop=Exception sending context destroyed event to listener instance of class {0}
coyoteRequest.attributeEvent=Exception thrown by attributes event listener
+coyoteRequest.parseMultipart=Exception thrown whilst processing multipart
coyoteRequest.parseParameters=Exception thrown whilst processing POSTed parameters
coyoteRequest.postTooLarge=Parameters were not parsed because the size of the posted data was too big. Use the maxPostSize attribute of the connector to resolve this if the application should accept large POSTs.
coyoteRequest.noAuthenticator=No authenticator available for programmatic login
Modified: trunk/java/org/apache/catalina/connector/Request.java
===================================================================
--- trunk/java/org/apache/catalina/connector/Request.java 2009-04-19 17:17:15 UTC (rev 1017)
+++ trunk/java/org/apache/catalina/connector/Request.java 2009-04-19 17:37:46 UTC (rev 1018)
@@ -58,6 +58,7 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
@@ -108,6 +109,7 @@
import org.apache.tomcat.util.http.Parameters;
import org.apache.tomcat.util.http.ServerCookie;
import org.apache.tomcat.util.http.fileupload.DiskFileUpload;
+import org.apache.tomcat.util.http.fileupload.FileItem;
import org.apache.tomcat.util.http.mapper.MappingData;
@@ -361,6 +363,12 @@
protected static int CACHED_POST_LEN = 8192;
protected byte[] postData = null;
+
+ /**
+ * Parts associated with the request.
+ */
+ protected Map<String, Part> parts = null;
+
/**
* Hash map used in the getParametersMap method.
@@ -491,6 +499,7 @@
attributes.clear();
notes.clear();
cookies = null;
+ parts = null;
if (session != null) {
session.endAccess();
@@ -2689,7 +2698,40 @@
}
+
+ /**
+ * Parse multipart.
+ */
+ protected void parseMultipart() {
+
+ // FIXME: Stub configuration from the example
+ DiskFileUpload fu = new DiskFileUpload();
+ // maximum size before a FileUploadException will be thrown
+ fu.setSizeMax(1000000);
+ // maximum size that will be stored in memory
+ fu.setSizeThreshold(4096);
+ // the location for saving data that is larger than getSizeThreshold()
+ fu.setRepositoryPath("/tmp");
+ parts = new HashMap<String, Part>();
+ try {
+ Iterator<FileItem> items = fu.parseRequest(getRequest()).iterator();
+ while (items.hasNext()) {
+ FileItem fileItem = items.next();
+ parts.put(fileItem.getName(), fileItem);
+ }
+ } catch (IOException e) {
+ // Client disconnect
+ if (context.getLogger().isDebugEnabled()) {
+ context.getLogger().debug(
+ sm.getString("coyoteRequest.parseMultipart"), e);
+ }
+ return;
+ }
+
+ }
+
+
/**
* Read post body in an array.
*/
@@ -2975,24 +3017,23 @@
public Part getPart(String name) throws IllegalArgumentException {
- // FIXME: get the config from somewhere
- // TODO Auto-generated method stub
- return null;
+ if (parts == null) {
+ parseMultipart();
+ }
+ Part result = parts.get(name);
+ if (result == null) {
+ throw new IllegalArgumentException();
+ } else {
+ return result;
+ }
}
public Iterable<Part> getParts() {
- // FIXME: Stub from the example
- DiskFileUpload fu = new DiskFileUpload();
- // maximum size before a FileUploadException will be thrown
- fu.setSizeMax(1000000);
- // maximum size that will be stored in memory
- fu.setSizeThreshold(4096);
- // the location for saving data that is larger than getSizeThreshold()
- fu.setRepositoryPath("/tmp");
-
- // FIXME: Store the list in a field locally
- return fu.parseRequest(getRequest());
+ if (parts == null) {
+ parseMultipart();
+ }
+ return parts.values();
}
15 years
JBossWeb SVN: r1017 - in trunk: java/javax/servlet and 6 other directories.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-04-19 13:17:15 -0400 (Sun, 19 Apr 2009)
New Revision: 1017
Added:
trunk/java/javax/servlet/annotation/MultipartConfig.java
trunk/java/javax/servlet/http/Part.java
Modified:
trunk/ROADMAP.txt
trunk/java/javax/servlet/AsyncContext.java
trunk/java/javax/servlet/AsyncEvent.java
trunk/java/javax/servlet/AsyncListener.java
trunk/java/javax/servlet/DispatcherType.java
trunk/java/javax/servlet/FilterChain.java
trunk/java/javax/servlet/FilterRegistration.java
trunk/java/javax/servlet/Registration.java
trunk/java/javax/servlet/ServletContainerInitializer.java
trunk/java/javax/servlet/ServletContext.java
trunk/java/javax/servlet/ServletContextAttributeEvent.java
trunk/java/javax/servlet/ServletContextAttributeListener.java
trunk/java/javax/servlet/ServletContextEvent.java
trunk/java/javax/servlet/ServletContextListener.java
trunk/java/javax/servlet/ServletRegistration.java
trunk/java/javax/servlet/ServletRequest.java
trunk/java/javax/servlet/ServletRequestAttributeEvent.java
trunk/java/javax/servlet/ServletRequestEvent.java
trunk/java/javax/servlet/ServletRequestWrapper.java
trunk/java/javax/servlet/ServletResponse.java
trunk/java/javax/servlet/ServletResponseWrapper.java
trunk/java/javax/servlet/SessionCookieConfig.java
trunk/java/javax/servlet/SessionTrackingMode.java
trunk/java/javax/servlet/annotation/HandlesTypes.java
trunk/java/javax/servlet/annotation/WebFilter.java
trunk/java/javax/servlet/annotation/WebServlet.java
trunk/java/javax/servlet/http/Cookie.java
trunk/java/javax/servlet/http/HttpServletRequest.java
trunk/java/javax/servlet/http/HttpServletRequestWrapper.java
trunk/java/javax/servlet/http/HttpServletResponse.java
trunk/java/javax/servlet/http/HttpServletResponseWrapper.java
trunk/java/javax/servlet/http/HttpSession.java
trunk/java/javax/servlet/http/HttpSessionActivationListener.java
trunk/java/javax/servlet/http/HttpSessionAttributeListener.java
trunk/java/javax/servlet/http/HttpSessionBindingEvent.java
trunk/java/javax/servlet/http/HttpSessionEvent.java
trunk/java/javax/servlet/http/HttpSessionListener.java
trunk/java/org/apache/catalina/connector/Request.java
trunk/java/org/apache/catalina/connector/RequestFacade.java
trunk/java/org/apache/catalina/core/ClassLoadingAnnotationScanner.java
trunk/java/org/apache/catalina/core/DummyRequest.java
trunk/java/org/apache/catalina/startup/ContextConfig.java
trunk/java/org/apache/catalina/startup/TldConfig.java
trunk/java/org/apache/tomcat/util/http/fileupload/DefaultFileItem.java
trunk/java/org/apache/tomcat/util/http/fileupload/DefaultFileItemFactory.java
trunk/java/org/apache/tomcat/util/http/fileupload/DiskFileUpload.java
trunk/java/org/apache/tomcat/util/http/fileupload/FileItem.java
trunk/java/org/apache/tomcat/util/http/fileupload/FileItemFactory.java
trunk/java/org/apache/tomcat/util/http/fileupload/FileUploadBase.java
trunk/java/org/apache/tomcat/util/http/fileupload/FileUploadException.java
Log:
- Sync with API snapshot.
- The return types are not ok right now, so it won't build.
- Add the Part API to fileupload.
- Start refactoring TldConfig.
Modified: trunk/ROADMAP.txt
===================================================================
--- trunk/ROADMAP.txt 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/ROADMAP.txt 2009-04-19 17:17:15 UTC (rev 1017)
@@ -16,7 +16,7 @@
Other:
- Diagnostic and monitoring features (provided by the jopr/JON agent, as JBoss Web standalone seems too
- lightweight for embeddede jopr/JON to make sense)
+ lightweight for embedded jopr/JON to make sense)
- .net support like the php support (looks ok, but PHP is hard to use, how would this be different ?)
- fastcgi servlet (sounds useless)
- Java proxy (probably too many components needed to compete with mod_cluster, but a very basic HTTP proxy could be useful
Modified: trunk/java/javax/servlet/AsyncContext.java
===================================================================
--- trunk/java/javax/servlet/AsyncContext.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/javax/servlet/AsyncContext.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -46,7 +46,7 @@
* Repeated invocations of these methods will return the same AsyncContext
* instance, reinitialized as appropriate.
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public interface AsyncContext {
Modified: trunk/java/javax/servlet/AsyncEvent.java
===================================================================
--- trunk/java/javax/servlet/AsyncEvent.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/javax/servlet/AsyncEvent.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -42,7 +42,7 @@
* processing was started has finished processing through a call to
* {@link AsyncContext#complete} or has timed out.
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public class AsyncEvent {
Modified: trunk/java/javax/servlet/AsyncListener.java
===================================================================
--- trunk/java/javax/servlet/AsyncListener.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/javax/servlet/AsyncListener.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -46,7 +46,7 @@
* or {@link ServletRequest#startAsync(ServletRequest, ServletResponse)}
* completes or times out.
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public interface AsyncListener extends EventListener {
Modified: trunk/java/javax/servlet/DispatcherType.java
===================================================================
--- trunk/java/javax/servlet/DispatcherType.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/javax/servlet/DispatcherType.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -28,6 +28,8 @@
/**
* Enumeration of filter dispatcher types.
+ *
+ * @since Servlet 3.0
*/
public enum DispatcherType {
FORWARD,
Modified: trunk/java/javax/servlet/FilterChain.java
===================================================================
--- trunk/java/javax/servlet/FilterChain.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/javax/servlet/FilterChain.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -52,8 +52,6 @@
* limitations under the License.
*/
-
-
package javax.servlet;
import java.io.IOException;
@@ -76,8 +74,6 @@
*
* @param request the request to pass along the chain.
* @param response the response to pass along the chain.
- *
- * @since 2.3
*/
public void doFilter ( ServletRequest request, ServletResponse response ) throws IOException, ServletException;
Modified: trunk/java/javax/servlet/FilterRegistration.java
===================================================================
--- trunk/java/javax/servlet/FilterRegistration.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/javax/servlet/FilterRegistration.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -41,7 +41,7 @@
/**
* Interface through which a {@link Filter} may be further configured.
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public interface FilterRegistration extends Registration {
@@ -65,14 +65,12 @@
* from which this FilterRegistration was obtained
* @param servletNames the servlet names of the filter mapping
*
- * @return true if the update was successful, false otherwise
- *
* @throws IllegalArgumentException if <tt>servletNames</tt> is null or
* empty
* @throws IllegalStateException if the ServletContext from which this
* FilterRegistration was obtained has already been initialized
*/
- public boolean addMappingForServletNames(
+ public void addMappingForServletNames(
EnumSet<DispatcherType> dispatcherTypes, boolean isMatchAfter,
String... servletNames);
@@ -96,14 +94,12 @@
* from which this FilterRegistration was obtained
* @param urlPatterns the url patterns of the filter mapping
*
- * @return true if the update was successful, false otherwise
- *
* @throws IllegalArgumentException if <tt>urlPatterns</tt> is null or
* empty
* @throws IllegalStateException if the ServletContext from which this
* FilterRegistration was obtained has already been initialized
*/
- public boolean addMappingForUrlPatterns(
+ public void addMappingForUrlPatterns(
EnumSet<DispatcherType> dispatcherTypes, boolean isMatchAfter,
String... urlPatterns);
Modified: trunk/java/javax/servlet/Registration.java
===================================================================
--- trunk/java/javax/servlet/Registration.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/javax/servlet/Registration.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -37,12 +37,13 @@
package javax.servlet;
import java.util.Map;
+import java.util.Set;
/**
* Interface through which a {@link Servlet} or {@link Filter} may be
* further configured.
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public interface Registration {
@@ -80,14 +81,15 @@
*
* @param initParameters the initialization parameters
*
- * @return true if the update was successful, false otherwise
+ * @return the (possibly empty) Set of initialization parameter names
+ * that are in conflict
*
* @throws IllegalStateException if the ServletContext from which this
* Registration was obtained has already been initialized
* @throws IllegalArgumentException if the given map contains an
* initialization parameter with a <tt>null</tt> name or value
*/
- public boolean setInitParameters(Map<String, String> initParameters);
+ public Set<String> setInitParameters(Map<String, String> initParameters);
/**
* Interface through which a {@link Servlet} or {@link Filter} registered
Modified: trunk/java/javax/servlet/ServletContainerInitializer.java
===================================================================
--- trunk/java/javax/servlet/ServletContainerInitializer.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/javax/servlet/ServletContainerInitializer.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -35,10 +35,8 @@
*
*/
-
package javax.servlet;
-
import java.util.Set;
/**
@@ -51,19 +49,17 @@
*
* @see javax.servlet.annotation.HandlesTypes
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public interface ServletContainerInitializer {
+
/**
- *
* @param c The set of classes that an implementation of ServletContainerInitializer expressed interest on
* via the <tt>HandlesTypes</tt> annotation. If there is no <tt>HandlesTypes</tt> annotation on the implementation
* of the ServletContainerInitializer, a <tt>null</tt> set of classes will be passed
*
* @param ctx The <tt>ServletContext</tt> instance in which the types defined via the <tt>HandlesTypes</tt>
* are found.
- *
- * @since 3.0
*/
public void onStartup(Set<Class<?>> c, ServletContext ctx);
}
Modified: trunk/java/javax/servlet/ServletContext.java
===================================================================
--- trunk/java/javax/servlet/ServletContext.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/javax/servlet/ServletContext.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -103,9 +103,9 @@
*
* <p>The context path is the portion of the request URI that is used
* to select the context of the request. The context path always comes
- * first in a request URI. The path starts with a "/" character but does
- * not end with a "/" character. For servlets in the default (root)
- * context, this method returns "".
+ * first in a request URI. The path starts with a <tt>/</tt> character
+ * but does not end with a <tt>/</tt> character. For servlets in the
+ * default (root) context, this method returns "".
*
* <p>It is possible that a servlet container may match a context by
* more than one context path. In such cases the
@@ -120,7 +120,7 @@
*
* @see javax.servlet.http.HttpServletRequest#getContextPath()
*
- * @since 2.5
+ * @since Servlet 2.5
*/
public String getContextPath();
@@ -132,7 +132,7 @@
* <p>This method allows servlets to gain
* access to the context for various parts of the server, and as
* needed obtain {@link RequestDispatcher} objects from the context.
- * The given path must be begin with "/", is interpreted relative
+ * The given path must be begin with <tt>/</tt>, is interpreted relative
* to the server's document root and is matched against the context
* roots of other web applications hosted on this container.
*
@@ -176,9 +176,8 @@
* the MIME type is not known. The MIME type is determined
* by the configuration of the servlet container, and may be specified
* in a web application deployment descriptor. Common MIME
- * types are <code>"text/html"</code> and <code>"image/gif"</code>.
+ * types include <code>text/html</code> and <code>image/gif</code>.
*
- *
* @param file a <code>String</code> specifying the name of a file
*
* @return a <code>String</code> specifying the file's MIME type
@@ -191,43 +190,58 @@
* within the web application whose longest sub-path matches the
* supplied path argument.
*
- * Paths indicating subdirectory paths end with a '/'.
+ * <p>Paths indicating subdirectory paths end with a <tt>/</tt>.
*
- * The returned paths are all relative to the root of the web application
- * and have a leading '/'.
+ * <p>The returned paths are all relative to the root of the web
+ * application, or relative to the <tt>/META-INF/resources</tt>
+ * directory of a JAR file inside the web application's
+ * <tt>/WEB-INF/lib</tt> directory, and have a leading <tt>/</tt>.
*
- * For example, for a web application containing<br><br>
+ * <p>For example, for a web application containing:
*
- * /welcome.html<br>
- * /catalog/index.html<br>
- * /catalog/products.html<br>
- * /catalog/offers/books.html<br>
- * /catalog/offers/music.html<br>
- * /customer/login.jsp<br>
- * /WEB-INF/web.xml<br>
- * /WEB-INF/classes/com.acme.OrderServlet.class,<br><br>
- *
- * getResourcePaths("/") returns {"/welcome.html", "/catalog/",
- * "/customer/", "/WEB-INF/"}<br>
- * getResourcePaths("/catalog/") returns {"/catalog/index.html",
- * "/catalog/products.html", "/catalog/offers/"}.<br>
+ * <code><pre>
+ * /welcome.html
+ * /catalog/index.html
+ * /catalog/products.html
+ * /catalog/offers/books.html
+ * /catalog/offers/music.html
+ * /customer/login.jsp
+ * /WEB-INF/web.xml
+ * /WEB-INF/classes/com.acme.OrderServlet.class
+ * /WEB-INF/lib/catalog.jar!/META-INF/resources/catalog/moreOffers/books.html
+ * </pre></code>
*
- * @param path the partial path used to match the resources,
- * which must start with a /
+ * <tt>getResourcePaths("/")</tt> would return
+ * <tt>{"/welcome.html", "/catalog/", "/customer/", "/WEB-INF/"}</tt>,
+ * and <tt>getResourcePaths("/catalog/")</tt> would return
+ * <tt>{"/catalog/index.html", "/catalog/products.html",
+ * "/catalog/offers/", "/catalog/moreOffers/"}</tt>.
+ *
+ * @param path the partial path used to match the resources,
+ * which must start with a <tt>/</tt>
* @return a Set containing the directory listing, or null if there
* are no resources in the web application whose path
* begins with the supplied path.
*
- * @since 2.3
+ * @since Servlet 2.3
*/
public Set<String> getResourcePaths(String path);
/**
- * Returns a URL to the resource that is mapped to a specified
- * path. The path must begin with a "/" and is interpreted
- * as relative to the current context root.
+ * Returns a URL to the resource that is mapped to the given path.
*
+ * <p>The path must begin with a <tt>/</tt> and is interpreted
+ * as relative to the current context root,
+ * or relative to the <tt>/META-INF/resources</tt> directory
+ * of a JAR file inside the web application's <tt>/WEB-INF/lib</tt>
+ * directory.
+ * This method will first search the document root of the
+ * web application for the requested resource, before searching
+ * any of the JAR files inside <tt>/WEB-INF/lib</tt>.
+ * The order in which the JAR files inside <tt>/WEB-INF/lib</tt>
+ * are searched is undefined.
+ *
* <p>This method allows the servlet container to make a resource
* available to servlets from any source. Resources
* can be located on a local or remote
@@ -308,12 +322,15 @@
* a request to the resource or to include the resource in a response.
* The resource can be dynamic or static.
*
- * <p>The pathname must begin with a "/" and is interpreted as relative
- * to the current context root. Use <code>getContext</code> to obtain
- * a <code>RequestDispatcher</code> for resources in foreign contexts.
- * This method returns <code>null</code> if the <code>ServletContext</code>
- * cannot return a <code>RequestDispatcher</code>.
+ * <p>The pathname must begin with a <tt>/</tt> and is interpreted as
+ * relative to the current context root. Use <code>getContext</code>
+ * to obtain a <code>RequestDispatcher</code> for resources in foreign
+ * contexts.
*
+ * <p>This method returns <code>null</code> if the
+ * <code>ServletContext</code> cannot return a
+ * <code>RequestDispatcher</code>.
+ *
* @param path a <code>String</code> specifying the pathname
* to the resource
*
@@ -440,26 +457,36 @@
/**
- * Returns a <code>String</code> containing the real path
- * for a given virtual path. For example, the path "/index.html"
- * returns the absolute file path on the server's filesystem would be
- * served by a request for "http://host/contextPath/index.html",
- * where contextPath is the context path of this ServletContext..
+ * Gets the <i>real</i> path corresponding to the given
+ * <i>virtual</i> path.
*
+ * <p>For example, if <tt>path</tt> is equal to <tt>/index.html</tt>,
+ * this method will return the absolute file path on the server's
+ * filesystem to which a request of the form
+ * <tt>http://<host>:<port>/<contextPath>/index.html</tt>
+ * would be mapped, where <tt><contextPath></tt> corresponds to the
+ * context path of this ServletContext.
+ *
* <p>The real path returned will be in a form
* appropriate to the computer and operating system on
* which the servlet container is running, including the
- * proper path separators. This method returns <code>null</code>
- * if the servlet container cannot translate the virtual path
- * to a real path for any reason (such as when the content is
- * being made available from a <code>.war</code> archive).
+ * proper path separators.
+ * Paths to resources located inside the <tt>/META-INF/resources</tt>
+ * directory of a JAR file inside the application's <tt>/WEB-INF/lib</tt>
+ * directory are returned using this format:
+ * <tt><absolute-file-path-on-disk>/WEB-INF/lib/<name-of-jar>!/META-INF/resources/<path></tt>,
+ * where <tt><path></tt> corresponds to the <tt>path</tt>
+ * argument passed to this method.
*
+ * <p>This method returns <code>null</code> if the servlet container
+ * is unable to translate the given <i>virtual</i> path to a
+ * <i>real</i> path.
*
- * @param path a <code>String</code> specifying a virtual path
+ * @param path the <i>virtual</i> path to be translated to a
+ * <i>real</i> path
*
- *
- * @return a <code>String</code> specifying the real path,
- * or null if the translation cannot be performed
+ * @return the <i>real</i> path, or <tt>null</tt> if the
+ * translation cannot be performed
*/
public String getRealPath(String path);
@@ -490,7 +517,7 @@
* parameter does not exist.
*
* <p>This method can make available configuration information useful
- * to an entire "web application". For example, it can provide a
+ * to an entire web application. For example, it can provide a
* webmaster's email address or the name of a system that holds
* critical data.
*
@@ -534,7 +561,7 @@
* @throws IllegalStateException if this ServletContext has already
* been initialized
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public boolean setInitParameter(String name, String value);
@@ -542,7 +569,8 @@
/**
* Returns the servlet container attribute with the given name,
* or <code>null</code> if there is no attribute by that name.
- * An attribute allows a servlet container to give the
+ *
+ * <p>An attribute allows a servlet container to give the
* servlet additional information not
* already provided by this interface. See your
* server documentation for information about its attributes.
@@ -551,12 +579,12 @@
*
* <p>The attribute is returned as a <code>java.lang.Object</code>
* or some subclass.
- * Attribute names should follow the same convention as package
+ *
+ * <p>Attribute names should follow the same convention as package
* names. The Java Servlet API specification reserves names
* matching <code>java.*</code>, <code>javax.*</code>,
* and <code>sun.*</code>.
*
- *
* @param name a <code>String</code> specifying the name
* of the attribute
*
@@ -600,7 +628,6 @@
* matching <code>java.*</code>, <code>javax.*</code>, and
* <code>sun.*</code>.
*
- *
* @param name a <code>String</code> specifying the name
* of the attribute
*
@@ -619,8 +646,6 @@
* <p>If listeners are configured on the <code>ServletContext</code> the
* container notifies them accordingly.
*
- *
- *
* @param name a <code>String</code> specifying the name
* of the attribute to be removed
*/
@@ -632,11 +657,10 @@
* ServletContext as specified in the deployment descriptor for this
* web application by the display-name element.
*
- *
* @return The name of the web application or null if no name has been
* declared in the deployment descriptor.
*
- * @since 2.3
+ * @since Servlet 2.3
*/
public String getServletContextName();
@@ -661,7 +685,7 @@
* @throws IllegalStateException if this ServletContext has already
* been initialized
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public ServletRegistration.Dynamic addServlet(
String servletName, String className);
@@ -688,7 +712,7 @@
* @throws IllegalArgumentException if the given servlet instance
* implements {@link SingleThreadModel}
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public ServletRegistration.Dynamic addServlet(
String servletName, Servlet servlet);
@@ -711,7 +735,7 @@
* @throws IllegalStateException if this ServletContext has already
* been initialized
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public ServletRegistration.Dynamic addServlet(String servletName,
Class <? extends Servlet> servletClass);
@@ -733,7 +757,7 @@
* @throws ServletException if an error occurs during the instantiation
* of, or resource injection into the new Servlet
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public <T extends Servlet> T createServlet(Class<T> c)
throws ServletException;
@@ -747,7 +771,7 @@
* given <tt>servletName</tt>, or null if no ServletRegistration exists
* under that name in this ServletContext
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public ServletRegistration findServletRegistration(String servletName);
@@ -772,7 +796,7 @@
* @throws IllegalStateException if this ServletContext has already
* been initialized
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public FilterRegistration.Dynamic addFilter(
String filterName, String className);
@@ -797,7 +821,7 @@
* @throws IllegalStateException if this ServletContext has already
* been initialized
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public FilterRegistration.Dynamic addFilter(
String filterName, Filter filter);
@@ -820,7 +844,7 @@
* @throws IllegalStateException if this ServletContext has already
* been initialized
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public FilterRegistration.Dynamic addFilter(String filterName,
Class <? extends Filter> filterClass);
@@ -842,7 +866,7 @@
* @throws ServletException if an error occurs during the instantiation
* of, or resource injection into the new Filter
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public <T extends Filter> T createFilter(Class<T> c)
throws ServletException;
@@ -856,7 +880,7 @@
* given <tt>filterName</tt>, or null if no FilterRegistration exists
* under that name in this ServletContext
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public FilterRegistration findFilterRegistration(String filterName);
@@ -873,7 +897,7 @@
* various properties of the session tracking cookies created on
* behalf of this <tt>ServletContext</tt> may be configured
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public SessionCookieConfig getSessionCookieConfig();
@@ -898,7 +922,7 @@
* or if <tt>sessionTrackingModes</tt> specifies a session tracking mode
* that is not supported by the servlet container
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public void setSessionTrackingModes(Set<SessionTrackingMode> sessionTrackingModes);
@@ -910,7 +934,7 @@
* @return set of the session tracking modes supported by default for
* this <tt>ServletContext</tt>
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public Set<SessionTrackingMode> getDefaultSessionTrackingModes();
@@ -929,7 +953,7 @@
* @return set of the session tracking modes in effect for this
* <tt>ServletContext</tt>
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public Set<SessionTrackingMode> getEffectiveSessionTrackingModes();
Modified: trunk/java/javax/servlet/ServletContextAttributeEvent.java
===================================================================
--- trunk/java/javax/servlet/ServletContextAttributeEvent.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/javax/servlet/ServletContextAttributeEvent.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -52,49 +52,58 @@
* limitations under the License.
*/
-
-
package javax.servlet;
+/**
+ * Event class for notifications about changes to the attributes of
+ * the ServletContext of a web application.
+ *
+ * @see ServletContextAttributeListener
+ *
+ * @since Servlet 2.3
+ */
- /**
- * This is the event class for notifications about changes to the attributes of the
- * servlet context of a web application.
- * @see ServletContextAttributeListener
- * @since v 2.3
- */
-
public class ServletContextAttributeEvent extends ServletContextEvent {
- private String name;
- private Object value;
- /** Construct a ServletContextAttributeEvent from the given context for the
- ** given attribute name and attribute value.
- */
- public ServletContextAttributeEvent(ServletContext source, String name, Object value) {
- super(source);
- this.name = name;
- this.value = value;
- }
+ private String name;
+ private Object value;
+
+ /**
+ * Constructs a ServletContextAttributeEvent from the given
+ * ServletContext, attribute name, and attribute value.
+ *
+ * @param source the ServletContext whose attribute changed
+ * @param name the name of the ServletContext attribute that changed
+ * @param value the value of the ServletContext attribute that changed
+ */
+ public ServletContextAttributeEvent(ServletContext source,
+ String name, Object value) {
+ super(source);
+ this.name = name;
+ this.value = value;
+ }
- /**
- * Return the name of the attribute that changed on the ServletContext.
- *
- */
- public String getName() {
- return this.name;
- }
+ /**
+ * Gets the name of the ServletContext attribute that changed.
+ *
+ * @return the name of the ServletContext attribute that changed
+ */
+ public String getName() {
+ return this.name;
+ }
- /**
- * Returns the value of the attribute that has been added, removed, or replaced.
- * If the attribute was added, this is the value of the attribute. If the attribute was
- * removed, this is the value of the removed attribute. If the attribute was replaced, this
- * is the old value of the attribute.
- *
- */
-
- public Object getValue() {
- return this.value;
- }
+ /**
+ * Gets the value of the ServletContext attribute that changed.
+ *
+ * <p>If the attribute was added, this is the value of the attribute.
+ * If the attribute was removed, this is the value of the removed
+ * attribute. If the attribute was replaced, this is the old value of
+ * the attribute.
+ *
+ * @return the value of the ServletContext attribute that changed
+ */
+ public Object getValue() {
+ return this.value;
+ }
}
Modified: trunk/java/javax/servlet/ServletContextAttributeListener.java
===================================================================
--- trunk/java/javax/servlet/ServletContextAttributeListener.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/javax/servlet/ServletContextAttributeListener.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -61,7 +61,7 @@
* To receive notification events, the implementation class
* must be configured in the deployment descriptor for the web application.
* @see ServletContextAttributeEvent
- * @since v 2.3
+ * @since Servlet 2.3
*/
public interface ServletContextAttributeListener extends EventListener {
Modified: trunk/java/javax/servlet/ServletContextEvent.java
===================================================================
--- trunk/java/javax/servlet/ServletContextEvent.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/javax/servlet/ServletContextEvent.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -61,7 +61,8 @@
* This is the event class for notifications about changes to
* the servlet context of a web application.
* @see ServletContextListener
- * @since v 2.3
+ *
+ * @since Servlet 2.3
*/
public class ServletContextEvent extends java.util.EventObject {
Modified: trunk/java/javax/servlet/ServletContextListener.java
===================================================================
--- trunk/java/javax/servlet/ServletContextListener.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/javax/servlet/ServletContextListener.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -66,7 +66,8 @@
* must be configured in the deployment descriptor for the web
* application.
* @see ServletContextEvent
- * @since v 2.3
+ *
+ * @since Servlet 2.3
*/
public interface ServletContextListener extends EventListener {
Modified: trunk/java/javax/servlet/ServletRegistration.java
===================================================================
--- trunk/java/javax/servlet/ServletRegistration.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/javax/servlet/ServletRegistration.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -36,10 +36,12 @@
package javax.servlet;
+import java.util.*;
+
/**
* Interface through which a {@link Servlet} may be further configured.
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public interface ServletRegistration extends Registration {
@@ -47,16 +49,20 @@
* Adds a servlet mapping with the given URL patterns for the Servlet
* represented by this ServletRegistration.
*
+ * <p>If any of the specified URL patterns are already mapped to a
+ * different Servlet, no updates will be performed.
+ *
* @param urlPatterns the URL patterns of the servlet mapping
*
- * @return true if the update was successful, false otherwise
+ * @return the (possibly empty) Set of URL patterns that are already
+ * mapped to a different Servlet
*
* @throws IllegalArgumentException if <tt>urlPatterns</tt> is null
* or empty
* @throws IllegalStateException if the ServletContext from which this
* ServletRegistration was obtained has already been initialized
*/
- public boolean addMapping(String... urlPatterns);
+ public Set<String> addMapping(String... urlPatterns);
/**
* Interface through which a {@link Servlet} registered via one of the
Modified: trunk/java/javax/servlet/ServletRequest.java
===================================================================
--- trunk/java/javax/servlet/ServletRequest.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/javax/servlet/ServletRequest.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -557,7 +557,7 @@
*
* @return an integer specifying the port number
*
- * @since 2.4
+ * @since Servlet 2.4
*/
public int getRemotePort();
@@ -569,7 +569,7 @@
* @return a <code>String</code> containing the host
* name of the IP on which the request was received.
*
- * @since 2.4
+ * @since Servlet 2.4
*/
public String getLocalName();
@@ -581,7 +581,7 @@
* @return a <code>String</code> containing the
* IP address on which the request was received.
*
- * @since 2.4
+ * @since Servlet 2.4
*
*/
public String getLocalAddr();
@@ -593,7 +593,7 @@
*
* @return an integer specifying the port number
*
- * @since 2.4
+ * @since Servlet 2.4
*/
public int getLocalPort();
@@ -605,7 +605,7 @@
* @return the servlet context to which this servlet request was last
* dispatched
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public ServletContext getServletContext();
@@ -651,7 +651,7 @@
* {@link AsyncContext#dispatch}, or if the response has already been
* closed
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public AsyncContext startAsync() throws IllegalStateException;
@@ -719,7 +719,7 @@
* {@link AsyncContext#dispatch}, or if the response has already been
* closed
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public AsyncContext startAsync(ServletRequest servletRequest,
ServletResponse servletResponse)
@@ -733,14 +733,15 @@
* {@link #startAsync} or
* {@link #startAsync(ServletRequest,ServletResponse)} on it.
*
- * <p>If this request has been dispatched using one of the
- * {@link AsyncContext#dispatch} methods since it was put into
- * asynchronous mode, this method returns <tt>false</tt>.
+ * <p>This method returns <tt>false</tt> if this request was
+ * put into asynchronous mode, but has since been dispatched using
+ * one of the {@link AsyncContext#dispatch} methods or released
+ * from asynchronous mode via a call to {@link AsyncContext#complete}.
*
* @return true if this request has been put into asynchronous mode,
* false otherwise
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public boolean isAsyncStarted();
@@ -756,7 +757,7 @@
* @return true if this request supports asynchronous operation, false
* otherwise
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public boolean isAsyncSupported();
@@ -775,7 +776,7 @@
* into asynchronous mode, i.e., if neither {@link #startAsync} nor
* {@link #startAsync(ServletRequest,ServletResponse)} has been called
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public AsyncContext getAsyncContext();
@@ -797,7 +798,7 @@
*
* @param listener the AsyncListener to be registered
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public void addAsyncListener(AsyncListener listener);
@@ -831,7 +832,7 @@
* @param servletResponse the ServletResponse that will be included
* in the AsyncEvent
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public void addAsyncListener(AsyncListener listener,
ServletRequest servletRequest,
@@ -872,7 +873,7 @@
* unless within the scope of a dispatch resulting from an
* {@link AsyncContext#dispatch}
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public void setAsyncTimeout(long timeout);
@@ -892,7 +893,7 @@
* @return the timeout in milliseconds for any asynchronous
* operations started on this request
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public long getAsyncTimeout();
@@ -926,7 +927,7 @@
*
* @see DispatcherType
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public DispatcherType getDispatcherType();
}
Modified: trunk/java/javax/servlet/ServletRequestAttributeEvent.java
===================================================================
--- trunk/java/javax/servlet/ServletRequestAttributeEvent.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/javax/servlet/ServletRequestAttributeEvent.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -61,7 +61,7 @@
* This is the event class for notifications of changes to the
* attributes of the servlet request in an application.
* @see ServletRequestAttributeListener
- * @since Servlet 2.4
+ * @since Servlet 2.4
*/
public class ServletRequestAttributeEvent extends ServletRequestEvent {
Modified: trunk/java/javax/servlet/ServletRequestEvent.java
===================================================================
--- trunk/java/javax/servlet/ServletRequestEvent.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/javax/servlet/ServletRequestEvent.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -63,7 +63,7 @@
* The source of the event
* is the ServletContext of this web application.
* @see ServletRequestListener
- * @since Servlet 2.4
+ * @since Servlet 2.4
*/
public class ServletRequestEvent extends java.util.EventObject {
Modified: trunk/java/javax/servlet/ServletRequestWrapper.java
===================================================================
--- trunk/java/javax/servlet/ServletRequestWrapper.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/javax/servlet/ServletRequestWrapper.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -69,7 +69,7 @@
*
* @see javax.servlet.ServletRequest
*
- * @since 2.3
+ * @since Servlet 2.3
*/
public class ServletRequestWrapper implements ServletRequest {
@@ -341,7 +341,7 @@
* The default behavior of this method is to return
* getRemotePort() on the wrapped request object.
*
- * @since 2.4
+ * @since Servlet 2.4
*/
public int getRemotePort(){
return this.request.getRemotePort();
@@ -352,7 +352,7 @@
* The default behavior of this method is to return
* getLocalName() on the wrapped request object.
*
- * @since 2.4
+ * @since Servlet 2.4
*/
public String getLocalName(){
return this.request.getLocalName();
@@ -363,7 +363,7 @@
* The default behavior of this method is to return
* getLocalAddr() on the wrapped request object.
*
- * @since 2.4
+ * @since Servlet 2.4
*/
public String getLocalAddr(){
return this.request.getLocalAddr();
@@ -374,7 +374,7 @@
* The default behavior of this method is to return
* getLocalPort() on the wrapped request object.
*
- * @since 2.4
+ * @since Servlet 2.4
*/
public int getLocalPort(){
return this.request.getLocalPort();
@@ -388,7 +388,7 @@
* @return the servlet context to which the wrapped servlet request was
* last dispatched
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public ServletContext getServletContext() {
return request.getServletContext();
@@ -412,7 +412,7 @@
*
* @see ServletRequest#startAsync
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public AsyncContext startAsync() throws IllegalStateException {
return request.startAsync();
@@ -441,7 +441,7 @@
*
* @see ServletRequest#startAsync(ServletRequest, ServletResponse)
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public AsyncContext startAsync(ServletRequest servletRequest,
ServletResponse servletResponse)
@@ -458,7 +458,7 @@
*
* @see ServletRequest#isAsyncStarted
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public boolean isAsyncStarted() {
return request.isAsyncStarted();
@@ -473,7 +473,7 @@
*
* @see ServletRequest#isAsyncSupported
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public boolean isAsyncSupported() {
return request.isAsyncSupported();
@@ -497,7 +497,7 @@
*
* @see ServletRequest#getAsyncContext
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public AsyncContext getAsyncContext() {
return request.getAsyncContext();
@@ -512,7 +512,7 @@
*
* @see ServletRequest#addAsyncListener(AsyncListener)
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public void addAsyncListener(AsyncListener listener) {
request.addAsyncListener(listener);
@@ -533,7 +533,7 @@
* @see ServletRequest#addAsyncListener(AsyncListener, ServletRequest,
* ServletResponse)
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public void addAsyncListener(AsyncListener listener,
ServletRequest servletRequest,
@@ -555,7 +555,7 @@
*
* @see ServletRequest#setAsyncTimeout
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public void setAsyncTimeout(long timeout) {
request.setAsyncTimeout(timeout);
@@ -571,7 +571,7 @@
*
* @see ServletRequest#getAsyncTimeout
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public long getAsyncTimeout() {
return request.getAsyncTimeout();
@@ -587,7 +587,7 @@
* @return true if this ServletRequestWrapper wraps the
* given ServletRequest instance, false otherwise
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public boolean isWrapperFor(ServletRequest wrapped) {
if (request == wrapped) {
@@ -613,7 +613,7 @@
* @throws IllegalArgumentException if the given class does not
* implement {@link ServletRequest}
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public boolean isWrapperFor(Class wrappedType) {
if (!ServletRequest.class.isAssignableFrom(wrappedType)) {
@@ -638,7 +638,7 @@
*
* @see ServletRequest#getDispatcherType
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public DispatcherType getDispatcherType() {
return request.getDispatcherType();
Modified: trunk/java/javax/servlet/ServletResponse.java
===================================================================
--- trunk/java/javax/servlet/ServletResponse.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/javax/servlet/ServletResponse.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -145,7 +145,7 @@
* <code>text/html; charset=UTF-8</code>,
* or null
*
- * @since 2.4
+ * @since Servlet 2.4
*/
public String getContentType();
@@ -251,7 +251,7 @@
* @see #setContentType
* #setLocale
*
- * @since 2.4
+ * @since Servlet 2.4
*
*/
@@ -384,7 +384,7 @@
* @see #isCommitted
* @see #reset
*
- * @since 2.3
+ * @since Servlet 2.3
*/
public void resetBuffer();
Modified: trunk/java/javax/servlet/ServletResponseWrapper.java
===================================================================
--- trunk/java/javax/servlet/ServletResponseWrapper.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/javax/servlet/ServletResponseWrapper.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -67,11 +67,10 @@
* This class implements the Wrapper or Decorator pattern. Methods default to
* calling through to the wrapped response object.
*
- * @author Various
- * @since v 2.3
+ * @author Various
+ * @since Servlet 2.3
*
- * @see javax.servlet.ServletResponse
- *
+ * @see javax.servlet.ServletResponse
*/
@@ -115,7 +114,7 @@
* The default behavior of this method is to call setCharacterEncoding(String charset)
* on the wrapped response object.
*
- * @since 2.4
+ * @since Servlet 2.4
*/
public void setCharacterEncoding(String charset) {
@@ -173,7 +172,7 @@
* The default behavior of this method is to return getContentType()
* on the wrapped response object.
*
- * @since 2.4
+ * @since Servlet 2.4
*/
public String getContentType() {
@@ -258,7 +257,7 @@
* @return true if this ServletResponseWrapper wraps the
* given ServletResponse instance, false otherwise
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public boolean isWrapperFor(ServletResponse wrapped) {
if (response == wrapped) {
@@ -284,7 +283,7 @@
* @throws IllegalArgumentException if the given class does not
* implement {@link ServletResponse}
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public boolean isWrapperFor(Class wrappedType) {
if (!ServletResponse.class.isAssignableFrom(wrappedType)) {
Modified: trunk/java/javax/servlet/SessionCookieConfig.java
===================================================================
--- trunk/java/javax/servlet/SessionCookieConfig.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/javax/servlet/SessionCookieConfig.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -33,7 +33,7 @@
* <p>An instance of this class is acquired by a call to
* {@link ServletContext#getSessionCookieConfig}.
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public interface SessionCookieConfig {
Modified: trunk/java/javax/servlet/SessionTrackingMode.java
===================================================================
--- trunk/java/javax/servlet/SessionTrackingMode.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/javax/servlet/SessionTrackingMode.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -29,7 +29,7 @@
/**
* Enumeration of session tracking modes.
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public enum SessionTrackingMode {
COOKIE,
Modified: trunk/java/javax/servlet/annotation/HandlesTypes.java
===================================================================
--- trunk/java/javax/servlet/annotation/HandlesTypes.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/javax/servlet/annotation/HandlesTypes.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -47,11 +47,9 @@
* This annotation is used to declare the types an instance of the
* ServletContainerInitializer can handle.
*
- * <p>
- *
* @see javax.servlet.ServletContainerInitializer
*
- * @since 3.0
+ * @since Servlet 3.0
*/
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
Added: trunk/java/javax/servlet/annotation/MultipartConfig.java
===================================================================
--- trunk/java/javax/servlet/annotation/MultipartConfig.java (rev 0)
+++ trunk/java/javax/servlet/annotation/MultipartConfig.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -0,0 +1,71 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 1997-2008 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can obtain
+ * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
+ * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
+ * Sun designates this particular file as subject to the "Classpath" exception
+ * as provided by Sun in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the License
+ * Header, with the fields enclosed by brackets [] replaced by your own
+ * identifying information: "Portions Copyrighted [year]
+ * [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+
+package javax.servlet.annotation;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+
+(a)Target(ElementType.TYPE)
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface MultipartConfig {
+ /**
+ * The directory location where files will be stored
+ *
+ */
+ String location() default "";
+
+ /**
+ * the maximum size allowed for files uploaded
+ *
+ */
+ int maxFileSize() default 0;
+
+ /**
+ * The maximum size of a multi-part/form-data request allowed
+ *
+ */
+ int maxRequestSize() default 0;
+
+ /**
+ * The size threshold after which the file will be written to disk
+ *
+ */
+ int fileSizeThreshold() default 0;
+}
Modified: trunk/java/javax/servlet/annotation/WebFilter.java
===================================================================
--- trunk/java/javax/servlet/annotation/WebFilter.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/javax/servlet/annotation/WebFilter.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -52,7 +52,7 @@
*
* @see javax.servlet.Filter
*
- * @since 3.0
+ * @since Servlet 3.0
*/
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@@ -118,11 +118,4 @@
*/
boolean asyncSupported() default false;
- /**
- * The timeout for asynchronous operations initiated by the
- * filter.
- *
- * @see javax.servlet.ServletRequest#setAsyncTimeout
- */
- long asyncTimeout() default 60000;
}
Modified: trunk/java/javax/servlet/annotation/WebServlet.java
===================================================================
--- trunk/java/javax/servlet/annotation/WebServlet.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/javax/servlet/annotation/WebServlet.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -52,7 +52,7 @@
*
* @see javax.servlet.Servlet
*
- * @since 3.0
+ * @since Servlet 3.0
*/
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@@ -94,14 +94,6 @@
boolean asyncSupported() default false;
/**
- * The timeout for asynchronous operations initiated by the
- * servlet.
- *
- * @see javax.servlet.ServletRequest#setAsyncTimeout
- */
- long asyncTimeout() default 60000;
-
- /**
* The small-icon of the servlet
*/
String smallIcon() default "";
Modified: trunk/java/javax/servlet/http/Cookie.java
===================================================================
--- trunk/java/javax/servlet/http/Cookie.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/javax/servlet/http/Cookie.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -586,7 +586,7 @@
* @param isHttpOnly true if this cookie is to be marked as
* <i>HttpOnly</i>, false otherwise
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public void setHttpOnly(boolean isHttpOnly) {
this.isHttpOnly = isHttpOnly;
@@ -598,7 +598,7 @@
* @return true if this cookie has been marked as <i>HttpOnly</i>,
* false otherwise
*
- * @since 3.0
+ * @since Servlet 3.0
*/
public boolean isHttpOnly() {
return isHttpOnly;
Modified: trunk/java/javax/servlet/http/HttpServletRequest.java
===================================================================
--- trunk/java/javax/servlet/http/HttpServletRequest.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/javax/servlet/http/HttpServletRequest.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -788,7 +788,28 @@
*
* @exception ServletException ff logout fails.
*/
- public void logout() throws ServletException;
+ public void logout() throws ServletException;
+
+ /**
+ * Retrieves all the parts of the multi-part/form-data http message
+ *
+ * @return An <code>Iterable</code> for all the parts of the multi-part/form-data request
+ */
+ public Iterable<Part> getParts();
+
+ /**
+ * Returns the part specified by the name.
+ *
+ * @param name the name of the part
+ * @return The part being requested for by name.
+ * @exception IllegalArgumentException If the name specified does not exist
+ *
+ */
+ public Part getPart(String name) throws IllegalArgumentException;
+
+
+
+
}
Modified: trunk/java/javax/servlet/http/HttpServletRequestWrapper.java
===================================================================
--- trunk/java/javax/servlet/http/HttpServletRequestWrapper.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/javax/servlet/http/HttpServletRequestWrapper.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -60,16 +60,15 @@
import java.util.Enumeration;
/**
+ * Provides a convenient implementation of the HttpServletRequest interface
+ * that can be subclassed by developers wishing to adapt the request to a
+ * Servlet.
+ *
+ * <p>This class implements the Wrapper or Decorator pattern. Methods default
+ * to calling through to the wrapped request object.
*
- * Provides a convenient implementation of the HttpServletRequest interface that
- * can be subclassed by developers wishing to adapt the request to a Servlet.
- * This class implements the Wrapper or Decorator pattern. Methods default to
- * calling through to the wrapped request object.
- *
- *
- * @see javax.servlet.http.HttpServletRequest
- * @since v 2.3
- *
+ * @see javax.servlet.http.HttpServletRequest
+ * @since Servlet 2.3
*/
@@ -328,4 +327,28 @@
public void logout() throws ServletException {
this._getHttpServletRequest().logout();
}
+
+ /**
+ * Retrieves all the parts of the multi-part/form-data http message
+ *
+ * @return An <code>Iterable</code> for all the parts of the multi-part/form-data request
+ */
+ public Iterable<Part> getParts() {
+ return this._getHttpServletRequest().getParts();
+ }
+
+ /**
+ * Returns the part specified by the name.
+ *
+ * @param name the name of the part
+ * @return The part being requested for by name.
+ * @exception IllegalArgumentException If the name specified does not exist
+ *
+ */
+ public Part getPart(String name) throws IllegalArgumentException {
+ return this._getHttpServletRequest().getPart(name);
+
+ }
+
+
}
Modified: trunk/java/javax/servlet/http/HttpServletResponse.java
===================================================================
--- trunk/java/javax/servlet/http/HttpServletResponse.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/javax/servlet/http/HttpServletResponse.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -343,9 +343,9 @@
*
* @see #sendError
*/
-
public void setStatus(int sc);
+
/**
* @deprecated As of version 2.1, due to ambiguous meaning of the
* message parameter. To set a status code
@@ -357,7 +357,6 @@
* @param sc the status code
* @param sm the status message
*/
-
public void setStatus(int sc, String sm);
@@ -365,6 +364,8 @@
* Gets the current status code of this response.
*
* @return the current status code of this response
+ *
+ * @since Servlet 3.0
*/
public int getStatus();
@@ -385,6 +386,8 @@
* @return the value of the response header with the given name,
* or <tt>null</tt> if no header with the given name has been set
* on this response
+ *
+ * @since Servlet 3.0
*/
public String getHeader(String name);
@@ -403,6 +406,8 @@
* @return the values of the response header with the given name,
* or an empty <tt>Iterable</tt> if no header with the given name
* has been set on this response
+ *
+ * @since Servlet 3.0
*/
public Iterable<String> getHeaders(String name);
@@ -418,6 +423,8 @@
*
* @return the names of the headers of this response, or an empty
* <tt>Iterable</tt> if no headers have been set on this response
+ *
+ * @since Servlet 3.0
*/
public Iterable<String> getHeaderNames();
Modified: trunk/java/javax/servlet/http/HttpServletResponseWrapper.java
===================================================================
--- trunk/java/javax/servlet/http/HttpServletResponseWrapper.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/javax/servlet/http/HttpServletResponseWrapper.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -67,11 +67,10 @@
* This class implements the Wrapper or Decorator pattern. Methods default to
* calling through to the wrapped response object.
*
- * @author Various
- * @since v 2.3
+ * @author Various
+ * @since Servlet 2.3
*
- * @see javax.servlet.http.HttpServletResponse
- *
+ * @see javax.servlet.http.HttpServletResponse
*/
public class HttpServletResponseWrapper extends ServletResponseWrapper implements HttpServletResponse {
Modified: trunk/java/javax/servlet/http/HttpSession.java
===================================================================
--- trunk/java/javax/servlet/http/HttpSession.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/javax/servlet/http/HttpSession.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -164,7 +164,7 @@
* Returns the ServletContext to which this session belongs.
*
* @return The ServletContext object for the web application
- * @since 2.3
+ * @since Servlet 2.3
*/
public ServletContext getServletContext();
Modified: trunk/java/javax/servlet/http/HttpSessionActivationListener.java
===================================================================
--- trunk/java/javax/servlet/http/HttpSessionActivationListener.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/javax/servlet/http/HttpSessionActivationListener.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -64,7 +64,7 @@
** or persists sessions is required to notify all attributes bound to sessions
** implementing HttpSessionActivationListener.
**
- * @since 2.3
+ * @since Servlet 2.3
*/
public interface HttpSessionActivationListener extends EventListener {
Modified: trunk/java/javax/servlet/http/HttpSessionAttributeListener.java
===================================================================
--- trunk/java/javax/servlet/http/HttpSessionAttributeListener.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/javax/servlet/http/HttpSessionAttributeListener.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -61,7 +61,7 @@
/** This listener interface can be implemented in order to
* get notifications of changes to the attribute lists of sessions within
* this web application.
- * @since v 2.3
+ * @since Servlet 2.3
*/
public interface HttpSessionAttributeListener extends EventListener {
Modified: trunk/java/javax/servlet/http/HttpSessionBindingEvent.java
===================================================================
--- trunk/java/javax/servlet/http/HttpSessionBindingEvent.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/javax/servlet/http/HttpSessionBindingEvent.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -174,7 +174,7 @@
* removed (or unbound), this is the value of the removed attribute. If the attribute was replaced, this
* is the old value of the attribute.
*
- * @since 2.3
+ * @since Servlet 2.3
*/
public Object getValue() {
Modified: trunk/java/javax/servlet/http/HttpSessionEvent.java
===================================================================
--- trunk/java/javax/servlet/http/HttpSessionEvent.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/javax/servlet/http/HttpSessionEvent.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -59,7 +59,7 @@
/** This is the class representing event notifications for
* changes to sessions within a web application.
- * @since v 2.3
+ * @since Servlet 2.3
*/
public class HttpSessionEvent extends java.util.EventObject {
/** Construct a session event from the given source.*/
Modified: trunk/java/javax/servlet/http/HttpSessionListener.java
===================================================================
--- trunk/java/javax/servlet/http/HttpSessionListener.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/javax/servlet/http/HttpSessionListener.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -64,7 +64,7 @@
* To receive notification events, the implementation class
* must be configured in the deployment descriptor for the web application.
* @see HttpSessionEvent
- * @since v 2.3
+ * @since Servlet 2.3
*/
public interface HttpSessionListener extends EventListener {
Added: trunk/java/javax/servlet/http/Part.java
===================================================================
--- trunk/java/javax/servlet/http/Part.java (rev 0)
+++ trunk/java/javax/servlet/http/Part.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -0,0 +1,180 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 1997-2008 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can obtain
+ * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
+ * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
+ * Sun designates this particular file as subject to the "Classpath" exception
+ * as provided by Sun in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the License
+ * Header, with the fields enclosed by brackets [] replaced by your own
+ * identifying information: "Portions Copyrighted [year]
+ * [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+
+package javax.servlet.http;
+
+import java.io.InputStream;
+import java.io.IOException;
+
+
+/**
+ * <p> This class represents a part or form item that was received within a
+ * <code>multipart/form-data</code> POST request.
+ *
+ */
+public interface Part {
+
+ /**
+ * Gets the content of this part as an <tt>InputStream</tt>
+ *
+ * @return The content of this part as an <tt>InputStream</tt>
+ * @throws IOException If an error occurs in retrieving the contet
+ * as an <tt>InputStream</tt>
+ */
+ public InputStream getInputStream() throws IOException;
+
+ /**
+ * Gets the content type of this part.
+ *
+ * @return The content type of this part.
+ */
+ public String getContentType();
+
+
+ /**
+ * Gets the name of this part
+ *
+ * @return The name of this part as a <tt>String</tt>
+ */
+ public String getName();
+
+
+
+ /**
+ * Returns the size of this fille.
+ *
+ * @return a <code>long</code> specifying the size of this part, in bytes.
+ */
+ public long getSize();
+
+
+ /**
+ * A convenience method to write this uploaded item to disk.
+ * <p>
+ * This method is not guaranteed to succeed if called more than once for
+ * the same part. This allows a particular implementation to use, for
+ * example, file renaming, where possible, rather than copying all of the
+ * underlying data, thus gaining a significant performance benefit.
+ *
+ * @param fileName a<code>String</code> specifying the file name which the stream is written out to.
+ * The file is created relative to the location as specified in the MultipartConfig
+ *
+ * @throws IOException if an error occurs.
+ */
+ public void write(String fileName) throws IOException;
+
+
+ /**
+ * Deletes the underlying storage for a file item, including deleting any
+ * associated temporary disk file.
+ *
+ * @throws IOException if an error occurs.
+ */
+ public void delete() throws IOException;
+
+ /**
+ *
+ * Returns the value of the specified mime header
+ * as a <code>String</code>. If the Part did not include a header
+ * of the specified name, this method returns <code>null</code>.
+ * If there are multiple headers with the same name, this method
+ * returns the first header in the part.
+ * The header name is case insensitive. You can use
+ * this method with any request header.
+ *
+ * @param name a <code>String</code> specifying the
+ * header name
+ *
+ * @return a <code>String</code> containing the
+ * value of the requested
+ * header, or <code>null</code>
+ * if the part does not
+ * have a header of that name
+ *
+ */
+
+ public String getHeader(String name);
+
+ /**
+ *
+ * Returns all the values of the specified Part header
+ * as an <code>Iterable</code> of <code>String</code> objects.
+ *
+ * <p>If the Part did not include any headers
+ * of the specified name, this method returns an empty
+ * <code>Iterable</code>.
+ * The header name is case insensitive. You can use
+ * this method with any Part header.
+ *
+ * @param name a <code>String</code> specifying the
+ * header name
+ *
+ * @return an <code>Iterable</code> containing
+ * the values of the requested header. If
+ * the Part does not have any headers of
+ * that name return an empty
+ * Iterable. If
+ * the container does not allow access to
+ * header information, return null
+ *
+ */
+
+ public Iterable<String> getHeaders(String name);
+
+ /**
+ *
+ * Returns an Iterable of all the header names
+ * this part contains. If the part has no
+ * headers, this method returns an empty Iterable.
+ *
+ * <p>Some servlet containers do not allow
+ * servlets to access headers using this method, in
+ * which case this method returns <code>null</code>
+ *
+ * @return an Iterable of all the
+ * header names sent with this
+ * part; if the part has
+ * no headers, an empty Iterable;
+ * if the servlet container does not
+ * allow servlets to use this method,
+ * <code>null</code>
+ *
+ *
+ */
+
+ public Iterable<String> getHeaderNames();
+
+}
Modified: trunk/java/org/apache/catalina/connector/Request.java
===================================================================
--- trunk/java/org/apache/catalina/connector/Request.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/org/apache/catalina/connector/Request.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -80,6 +80,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
+import javax.servlet.http.Part;
import org.apache.catalina.Container;
import org.apache.catalina.Context;
@@ -106,6 +107,7 @@
import org.apache.tomcat.util.http.FastHttpDateFormat;
import org.apache.tomcat.util.http.Parameters;
import org.apache.tomcat.util.http.ServerCookie;
+import org.apache.tomcat.util.http.fileupload.DiskFileUpload;
import org.apache.tomcat.util.http.mapper.MappingData;
@@ -2971,7 +2973,29 @@
throw new IllegalStateException();
}
-
+
+ public Part getPart(String name) throws IllegalArgumentException {
+ // FIXME: get the config from somewhere
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+ public Iterable<Part> getParts() {
+ // FIXME: Stub from the example
+ DiskFileUpload fu = new DiskFileUpload();
+ // maximum size before a FileUploadException will be thrown
+ fu.setSizeMax(1000000);
+ // maximum size that will be stored in memory
+ fu.setSizeThreshold(4096);
+ // the location for saving data that is larger than getSizeThreshold()
+ fu.setRepositoryPath("/tmp");
+
+ // FIXME: Store the list in a field locally
+ return fu.parseRequest(getRequest());
+ }
+
+
public String toString() {
StringBuffer buf = new StringBuffer();
buf.append(sm.getString("coyoteRequest.servletStack", Thread.currentThread().getName()));
@@ -3124,4 +3148,5 @@
}
+
}
Modified: trunk/java/org/apache/catalina/connector/RequestFacade.java
===================================================================
--- trunk/java/org/apache/catalina/connector/RequestFacade.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/org/apache/catalina/connector/RequestFacade.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -39,6 +39,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
+import javax.servlet.http.Part;
import org.apache.catalina.Globals;
import org.apache.catalina.core.ApplicationFilterChain;
@@ -1120,4 +1121,24 @@
request.logout();
}
+
+ public Part getPart(String name) throws IllegalArgumentException {
+ if (request == null) {
+ throw new IllegalStateException(
+ sm.getString("requestFacade.nullRequest"));
+ }
+
+ return request.getPart(name);
+ }
+
+
+ public Iterable<Part> getParts() {
+ if (request == null) {
+ throw new IllegalStateException(
+ sm.getString("requestFacade.nullRequest"));
+ }
+
+ return request.getParts();
+ }
+
}
Modified: trunk/java/org/apache/catalina/core/ClassLoadingAnnotationScanner.java
===================================================================
--- trunk/java/org/apache/catalina/core/ClassLoadingAnnotationScanner.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/org/apache/catalina/core/ClassLoadingAnnotationScanner.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -22,6 +22,7 @@
import java.util.jar.JarEntry;
import javax.servlet.annotation.HandlesTypes;
+import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebFilter;
import javax.servlet.annotation.WebInitParam;
import javax.servlet.annotation.WebListener;
@@ -40,6 +41,7 @@
try {
Class<?> clazz = context.getLoader().getClassLoader().loadClass(className);
if (clazz.isAnnotationPresent(HandlesTypes.class)
+ || clazz.isAnnotationPresent(MultipartConfig.class)
|| clazz.isAnnotationPresent(WebFilter.class)
|| clazz.isAnnotationPresent(WebInitParam.class)
|| clazz.isAnnotationPresent(WebListener.class)
Modified: trunk/java/org/apache/catalina/core/DummyRequest.java
===================================================================
--- trunk/java/org/apache/catalina/core/DummyRequest.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/org/apache/catalina/core/DummyRequest.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -44,6 +44,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
+import javax.servlet.http.Part;
import org.apache.catalina.Context;
import org.apache.catalina.Host;
@@ -289,6 +290,8 @@
public void login(String username, String password) throws ServletException {}
public void logout() throws ServletException {}
public long getAsyncTimeout() { return 0; }
+ public Part getPart(String name) throws IllegalArgumentException { return null; }
+ public Iterable<Part> getParts() { return null; }
}
Modified: trunk/java/org/apache/catalina/startup/ContextConfig.java
===================================================================
--- trunk/java/org/apache/catalina/startup/ContextConfig.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/org/apache/catalina/startup/ContextConfig.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -33,6 +33,7 @@
import javax.servlet.DispatcherType;
import javax.servlet.ServletContext;
import javax.servlet.annotation.HandlesTypes;
+import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebFilter;
import javax.servlet.annotation.WebInitParam;
import javax.servlet.annotation.WebListener;
@@ -315,6 +316,10 @@
HandlesTypes annotation = clazz.getAnnotation(HandlesTypes.class);
// FIXME: Ok, this is complex ....
}
+ if (clazz.isAnnotationPresent(MultipartConfig.class)) {
+ MultipartConfig annotation = clazz.getAnnotation(MultipartConfig.class);
+ // FIXME: Do something ....
+ }
if (clazz.isAnnotationPresent(WebFilter.class)) {
WebFilter annotation = clazz.getAnnotation(WebFilter.class);
// Add servlet filter
Modified: trunk/java/org/apache/catalina/startup/TldConfig.java
===================================================================
--- trunk/java/org/apache/catalina/startup/TldConfig.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/org/apache/catalina/startup/TldConfig.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -64,60 +64,58 @@
public final class TldConfig {
// Names of JARs that are known not to contain any TLDs
- private static HashSet<String> noTldJars;
+ private static HashSet<String> noDescriptorsJars;
private static org.jboss.logging.Logger log=
- org.jboss.logging.Logger.getLogger( TldConfig.class );
+ org.jboss.logging.Logger.getLogger(TldConfig.class);
/*
- * Initializes the set of JARs that are known not to contain any TLDs
+ * Initializes the set of JARs that are known not to contain any descriptors.
*/
static {
- noTldJars = new HashSet<String>();
+ noDescriptorsJars = new HashSet<String>();
// Bootstrap JARs
- noTldJars.add("bootstrap.jar");
- noTldJars.add("commons-daemon.jar");
- noTldJars.add("tomcat-juli.jar");
+ noDescriptorsJars.add("bootstrap.jar");
+ noDescriptorsJars.add("commons-daemon.jar");
+ noDescriptorsJars.add("tomcat-juli.jar");
// Main JARs
- noTldJars.add("annotations-api.jar");
- noTldJars.add("catalina.jar");
- noTldJars.add("catalina-ant.jar");
- noTldJars.add("catalina-ha.jar");
- noTldJars.add("catalina-tribes.jar");
- noTldJars.add("el-api.jar");
- noTldJars.add("jasper.jar");
- noTldJars.add("jasper-el.jar");
- noTldJars.add("jasper-jdt.jar");
- noTldJars.add("jsp-api.jar");
- noTldJars.add("servlet-api.jar");
- noTldJars.add("tomcat-coyote.jar");
- noTldJars.add("tomcat-dbcp.jar");
+ noDescriptorsJars.add("annotations-api.jar");
+ noDescriptorsJars.add("catalina.jar");
+ noDescriptorsJars.add("catalina-ant.jar");
+ noDescriptorsJars.add("el-api.jar");
+ noDescriptorsJars.add("jasper.jar");
+ noDescriptorsJars.add("jasper-el.jar");
+ noDescriptorsJars.add("jasper-jdt.jar");
+ noDescriptorsJars.add("jsp-api.jar");
+ noDescriptorsJars.add("servlet-api.jar");
+ noDescriptorsJars.add("tomcat-coyote.jar");
+ noDescriptorsJars.add("tomcat-dbcp.jar");
// i18n JARs
- noTldJars.add("tomcat-i18n-en.jar");
- noTldJars.add("tomcat-i18n-es.jar");
- noTldJars.add("tomcat-i18n-fr.jar");
- noTldJars.add("tomcat-i18n-ja.jar");
+ noDescriptorsJars.add("tomcat-i18n-en.jar");
+ noDescriptorsJars.add("tomcat-i18n-es.jar");
+ noDescriptorsJars.add("tomcat-i18n-fr.jar");
+ noDescriptorsJars.add("tomcat-i18n-ja.jar");
// Misc JARs not included with Tomcat
- noTldJars.add("ant.jar");
- noTldJars.add("commons-dbcp.jar");
- noTldJars.add("commons-beanutils.jar");
- noTldJars.add("commons-fileupload-1.0.jar");
- noTldJars.add("commons-pool.jar");
- noTldJars.add("commons-digester.jar");
- noTldJars.add("commons-logging.jar");
- noTldJars.add("commons-collections.jar");
- noTldJars.add("jmx.jar");
- noTldJars.add("jmx-tools.jar");
- noTldJars.add("xercesImpl.jar");
- noTldJars.add("xmlParserAPIs.jar");
- noTldJars.add("xml-apis.jar");
+ noDescriptorsJars.add("ant.jar");
+ noDescriptorsJars.add("commons-dbcp.jar");
+ noDescriptorsJars.add("commons-beanutils.jar");
+ noDescriptorsJars.add("commons-fileupload-1.0.jar");
+ noDescriptorsJars.add("commons-pool.jar");
+ noDescriptorsJars.add("commons-digester.jar");
+ noDescriptorsJars.add("commons-logging.jar");
+ noDescriptorsJars.add("commons-collections.jar");
+ noDescriptorsJars.add("jmx.jar");
+ noDescriptorsJars.add("jmx-tools.jar");
+ noDescriptorsJars.add("xercesImpl.jar");
+ noDescriptorsJars.add("xmlParserAPIs.jar");
+ noDescriptorsJars.add("xml-apis.jar");
// JARs from J2SE runtime
- noTldJars.add("sunjce_provider.jar");
- noTldJars.add("ldapsec.jar");
- noTldJars.add("localedata.jar");
- noTldJars.add("dnsns.jar");
- noTldJars.add("tools.jar");
- noTldJars.add("sunpkcs11.jar");
+ noDescriptorsJars.add("sunjce_provider.jar");
+ noDescriptorsJars.add("ldapsec.jar");
+ noDescriptorsJars.add("localedata.jar");
+ noDescriptorsJars.add("dnsns.jar");
+ noDescriptorsJars.add("tools.jar");
+ noDescriptorsJars.add("sunpkcs11.jar");
}
@@ -167,10 +165,10 @@
*/
public static void setNoTldJars(String jarNames) {
if (jarNames != null) {
- noTldJars.clear();
+ noDescriptorsJars.clear();
StringTokenizer tokenizer = new StringTokenizer(jarNames, ",");
while (tokenizer.hasMoreElements()) {
- noTldJars.add(tokenizer.nextToken());
+ noDescriptorsJars.add(tokenizer.nextToken());
}
}
}
@@ -251,40 +249,13 @@
public void execute() throws Exception {
long t1=System.currentTimeMillis();
- File tldCache=null;
-
- if (context instanceof StandardContext) {
- File workDir= (File)
- ((StandardContext)context).getServletContext().getAttribute(Globals.WORK_DIR_ATTR);
- //tldCache=new File( workDir, "tldCache.ser");
- }
-
- // Option to not rescan
- if( ! rescan ) {
- // find the cache
- if( tldCache!= null && tldCache.exists()) {
- // just read it...
- processCache(tldCache);
- return;
- }
- }
-
/*
* Acquire the list of TLD resource paths, possibly embedded in JAR
* files, to be processed
*/
Set resourcePaths = tldScanResourcePaths();
- Map jarPaths = getJarPaths();
+ Map<String, File> jarPaths = getJarPaths();
- // Check to see if we can use cached listeners
- if (tldCache != null && tldCache.exists()) {
- long lastModified = getLastModified(resourcePaths, jarPaths);
- if (lastModified < tldCache.lastModified()) {
- processCache(tldCache);
- return;
- }
- }
-
// Scan each accumulated resource path for TLDs to be processed
Iterator paths = resourcePaths.iterator();
while (paths.hasNext()) {
@@ -304,18 +275,6 @@
String list[] = getTldListeners();
- if( tldCache!= null ) {
- log.debug( "Saving tld cache: " + tldCache + " " + list.length);
- try {
- FileOutputStream out=new FileOutputStream(tldCache);
- ObjectOutputStream oos=new ObjectOutputStream( out );
- oos.writeObject( list );
- oos.close();
- } catch( IOException ex ) {
- ex.printStackTrace();
- }
- }
-
if( log.isDebugEnabled() )
log.debug( "Adding tld listeners:" + list.length);
for( int i=0; list!=null && i<list.length; i++ ) {
@@ -572,11 +531,11 @@
* @exception IOException if an input/output error occurs while
* accumulating the list of resource paths
*/
- private Set tldScanResourcePaths() throws IOException {
+ private Set<String> tldScanResourcePaths() throws IOException {
if (log.isDebugEnabled()) {
log.debug(" Accumulating TLD resource paths");
}
- Set resourcePaths = new HashSet();
+ Set<String> resourcePaths = new HashSet<String>();
// Accumulate resource paths explicitly listed in the web application
// deployment descriptor
@@ -675,9 +634,9 @@
*
* @return Map of JAR file paths
*/
- private Map getJarPaths() {
+ private Map<String, File> getJarPaths() {
- HashMap jarPathMap = null;
+ HashMap<String, File> jarPathMap = null;
ClassLoader webappLoader = Thread.currentThread().getContextClassLoader();
ClassLoader loader = webappLoader;
@@ -715,8 +674,8 @@
* that are not known not to contain any TLDs
*/
if (loader == webappLoader
- || noTldJars == null
- || !noTldJars.contains(file.getName())) {
+ || noDescriptorsJars == null
+ || !noDescriptorsJars.contains(file.getName())) {
if (jarPathMap == null) {
jarPathMap = new HashMap();
jarPathMap.put(path, file);
Modified: trunk/java/org/apache/tomcat/util/http/fileupload/DefaultFileItem.java
===================================================================
--- trunk/java/org/apache/tomcat/util/http/fileupload/DefaultFileItem.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/org/apache/tomcat/util/http/fileupload/DefaultFileItem.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -29,6 +29,7 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
+import java.util.Map;
/**
@@ -112,8 +113,14 @@
/**
* Output stream for this item.
*/
- private DeferredFileOutputStream dfos;
+ private transient DeferredFileOutputStream dfos;
+
+ /**
+ * Headers associated with the file item.
+ */
+ private Map<String, String> headers;
+
// ----------------------------------------------------------- Constructors
@@ -136,12 +143,14 @@
* exceed the threshold.
*/
DefaultFileItem(String fieldName, String contentType, boolean isFormField,
- String fileName, int sizeThreshold, File repository)
+ String fileName, Map<String, String> headers, int sizeThreshold,
+ File repository)
{
this.fieldName = fieldName;
this.contentType = contentType;
this.isFormField = isFormField;
this.fileName = fileName;
+ this.headers = headers;
this.sizeThreshold = sizeThreshold;
this.repository = repository;
}
@@ -338,7 +347,7 @@
*
* @exception Exception if an error occurs.
*/
- public void write(File file) throws Exception
+ public void write(File file) throws IOException
{
if (isInMemory())
{
@@ -517,6 +526,26 @@
}
+ public String getHeader(String name) {
+ return headers.get(name);
+ }
+
+
+ public Iterable<String> getHeaderNames() {
+ return headers.keySet();
+ }
+
+
+ public Iterable<String> getHeaders(String name) {
+ // FIXME: Create a Set out of the comma separated values
+ return null;
+ }
+
+
+ public void write(String fileName) throws IOException {
+ write(new File(fileName));
+ }
+
// --------------------------------------------------------- Public methods
@@ -605,4 +634,5 @@
return id;
}
+
}
Modified: trunk/java/org/apache/tomcat/util/http/fileupload/DefaultFileItemFactory.java
===================================================================
--- trunk/java/org/apache/tomcat/util/http/fileupload/DefaultFileItemFactory.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/org/apache/tomcat/util/http/fileupload/DefaultFileItemFactory.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -19,6 +19,7 @@
package org.apache.tomcat.util.http.fileupload;
import java.io.File;
+import java.util.Map;
/**
@@ -180,11 +181,12 @@
String fieldName,
String contentType,
boolean isFormField,
- String fileName
+ String fileName,
+ Map<String, String> headers
)
{
return new DefaultFileItem(fieldName, contentType,
- isFormField, fileName, sizeThreshold, repository);
+ isFormField, fileName, headers, sizeThreshold, repository);
}
}
Modified: trunk/java/org/apache/tomcat/util/http/fileupload/DiskFileUpload.java
===================================================================
--- trunk/java/org/apache/tomcat/util/http/fileupload/DiskFileUpload.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/org/apache/tomcat/util/http/fileupload/DiskFileUpload.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -190,7 +190,7 @@
* @exception FileUploadException if there are problems reading/parsing
* the request or storing files.
*/
- public List /* FileItem */ parseRequest(HttpServletRequest req,
+ public List<FileItem> parseRequest(HttpServletRequest req,
int sizeThreshold,
long sizeMax, String path)
throws FileUploadException
Modified: trunk/java/org/apache/tomcat/util/http/fileupload/FileItem.java
===================================================================
--- trunk/java/org/apache/tomcat/util/http/fileupload/FileItem.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/org/apache/tomcat/util/http/fileupload/FileItem.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -21,12 +21,13 @@
import java.io.File;
import java.io.IOException;
-import java.io.InputStream;
import java.io.OutputStream;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
+import javax.servlet.http.Part;
+
/**
* <p> This class represents a file or form item that was received within a
* <code>multipart/form-data</code> POST request.
@@ -55,47 +56,10 @@
* @version $Id$
*/
public interface FileItem
- extends Serializable
+ extends Part, Serializable
{
- // ------------------------------- Methods from javax.activation.DataSource
-
-
- /**
- * Returns an {@link java.io.InputStream InputStream} that can be
- * used to retrieve the contents of the file.
- *
- * @return An {@link java.io.InputStream InputStream} that can be
- * used to retrieve the contents of the file.
- *
- * @exception IOException if an error occurs.
- */
- InputStream getInputStream()
- throws IOException;
-
-
- /**
- * Returns the content type passed by the browser or <code>null</code> if
- * not defined.
- *
- * @return The content type passed by the browser or <code>null</code> if
- * not defined.
- */
- String getContentType();
-
-
- /**
- * Returns the original filename in the client's filesystem, as provided by
- * the browser (or other client software). In most cases, this will be the
- * base file name, without path information. However, some clients, such as
- * the Opera browser, do include path information.
- *
- * @return The original filename in the client's filesystem.
- */
- String getName();
-
-
// ------------------------------------------------------- FileItem methods
@@ -110,14 +74,6 @@
/**
- * Returns the size of the file item.
- *
- * @return The size of the file item, in bytes.
- */
- long getSize();
-
-
- /**
* Returns the contents of the file item as an array of bytes.
*
* @return The contents of the file item as an array of bytes.
@@ -167,20 +123,10 @@
*
* @exception Exception if an error occurs.
*/
- void write(File file) throws Exception;
+ void write(File file) throws IOException;
/**
- * Deletes the underlying storage for a file item, including deleting any
- * associated temporary disk file. Although this storage will be deleted
- * automatically when the <code>FileItem</code> instance is garbage
- * collected, this method can be used to ensure that this is done at an
- * earlier time, thus preserving system resources.
- */
- void delete();
-
-
- /**
* Returns the name of the field in the multipart form corresponding to
* this file item.
*
Modified: trunk/java/org/apache/tomcat/util/http/fileupload/FileItemFactory.java
===================================================================
--- trunk/java/org/apache/tomcat/util/http/fileupload/FileItemFactory.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/org/apache/tomcat/util/http/fileupload/FileItemFactory.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -18,7 +18,9 @@
package org.apache.tomcat.util.http.fileupload;
+import java.util.Map;
+
/**
* <p>A factory interface for creating {@link FileItem} instances. Factories
* can provide their own custom configuration, over and above that provided
@@ -48,6 +50,7 @@
String fieldName,
String contentType,
boolean isFormField,
- String fileName
+ String fileName,
+ Map<String, String> headers
);
}
Modified: trunk/java/org/apache/tomcat/util/http/fileupload/FileUploadBase.java
===================================================================
--- trunk/java/org/apache/tomcat/util/http/fileupload/FileUploadBase.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/org/apache/tomcat/util/http/fileupload/FileUploadBase.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -239,7 +239,7 @@
* @exception FileUploadException if there are problems reading/parsing
* the request or storing files.
*/
- public List /* FileItem */ parseRequest(HttpServletRequest req)
+ public List<FileItem> parseRequest(HttpServletRequest req)
throws FileUploadException
{
if (null == req)
@@ -247,7 +247,7 @@
throw new NullPointerException("req parameter");
}
- ArrayList items = new ArrayList();
+ ArrayList<FileItem> items = new ArrayList<FileItem>();
String contentType = req.getHeader(CONTENT_TYPE);
if ((null == contentType) || (!contentType.startsWith(MULTIPART)))
@@ -295,7 +295,7 @@
boolean nextPart = multi.skipPreamble();
while (nextPart)
{
- Map headers = parseHeaders(multi.readHeaders());
+ Map<String, String> headers = parseHeaders(multi.readHeaders());
String fieldName = getFieldName(headers);
if (fieldName != null)
{
@@ -456,14 +456,15 @@
*
* @exception FileUploadException if an error occurs.
*/
- protected FileItem createItem(Map /* String, String */ headers,
+ protected FileItem createItem(Map<String, String> headers,
boolean isFormField)
throws FileUploadException
{
return getFileItemFactory().createItem(getFieldName(headers),
getHeader(headers, CONTENT_TYPE),
isFormField,
- getFileName(headers));
+ getFileName(headers),
+ headers);
}
@@ -479,9 +480,9 @@
*
* @return A <code>Map</code> containing the parsed HTTP request headers.
*/
- protected Map /* String, String */ parseHeaders(String headerPart)
+ protected Map<String, String> parseHeaders(String headerPart)
{
- Map headers = new HashMap();
+ Map<String, String> headers = new HashMap<String, String>();
char buffer[] = new char[MAX_HEADER_SIZE];
boolean done = false;
int j = 0;
Modified: trunk/java/org/apache/tomcat/util/http/fileupload/FileUploadException.java
===================================================================
--- trunk/java/org/apache/tomcat/util/http/fileupload/FileUploadException.java 2009-04-17 12:02:55 UTC (rev 1016)
+++ trunk/java/org/apache/tomcat/util/http/fileupload/FileUploadException.java 2009-04-19 17:17:15 UTC (rev 1017)
@@ -18,7 +18,9 @@
package org.apache.tomcat.util.http.fileupload;
+import java.io.IOException;
+
/**
* Exception for errors encountered while processing the request.
*
@@ -26,7 +28,7 @@
* @version $Id$
*/
public class FileUploadException
- extends Exception
+ extends IOException
{
/**
15 years
JBossWeb SVN: r1016 - in trunk: java/org/apache/catalina/startup and 4 other directories.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-04-17 08:02:55 -0400 (Fri, 17 Apr 2009)
New Revision: 1016
Modified:
trunk/conf/catalina.properties
trunk/java/org/apache/catalina/startup/catalina.properties
trunk/java/org/apache/tomcat/util/buf/StringCache.java
trunk/java/org/apache/tomcat/util/http/ServerCookie.java
trunk/res/jboss/org/apache/catalina/startup/catalina.properties
trunk/webapps/docs/sysprops.xml
Log:
- Port JF's dedicated version switch flag, independent of strict servlet compliance.
- Change some other properties to org.apache.*.
Modified: trunk/conf/catalina.properties
===================================================================
--- trunk/conf/catalina.properties 2009-04-17 10:59:59 UTC (rev 1015)
+++ trunk/conf/catalina.properties 2009-04-17 12:02:55 UTC (rev 1016)
@@ -60,7 +60,7 @@
#
# String cache configuration.
-tomcat.util.buf.StringCache.byte.enabled=true
-#tomcat.util.buf.StringCache.char.enabled=true
-#tomcat.util.buf.StringCache.trainThreshold=500000
-#tomcat.util.buf.StringCache.cacheSize=5000
+org.apache.tomcat.util.buf.StringCache.byte.enabled=true
+#org.apache.tomcat.util.buf.StringCache.char.enabled=true
+#org.apache.tomcat.util.buf.StringCache.trainThreshold=500000
+#org.apache.tomcat.util.buf.StringCache.cacheSize=5000
Modified: trunk/java/org/apache/catalina/startup/catalina.properties
===================================================================
--- trunk/java/org/apache/catalina/startup/catalina.properties 2009-04-17 10:59:59 UTC (rev 1015)
+++ trunk/java/org/apache/catalina/startup/catalina.properties 2009-04-17 12:02:55 UTC (rev 1016)
@@ -60,7 +60,7 @@
#
# String cache configuration.
-tomcat.util.buf.StringCache.byte.enabled=true
-#tomcat.util.buf.StringCache.char.enabled=true
-#tomcat.util.buf.StringCache.trainThreshold=500000
-#tomcat.util.buf.StringCache.cacheSize=5000
+org.apache.tomcat.util.buf.StringCache.byte.enabled=true
+#org.apache.tomcat.util.buf.StringCache.char.enabled=true
+#org.apache.tomcat.util.buf.StringCache.trainThreshold=500000
+#org.apache.tomcat.util.buf.StringCache.cacheSize=5000
Modified: trunk/java/org/apache/tomcat/util/buf/StringCache.java
===================================================================
--- trunk/java/org/apache/tomcat/util/buf/StringCache.java 2009-04-17 10:59:59 UTC (rev 1015)
+++ trunk/java/org/apache/tomcat/util/buf/StringCache.java 2009-04-17 12:02:55 UTC (rev 1016)
@@ -41,23 +41,23 @@
* Enabled ?
*/
protected static boolean byteEnabled =
- ("true".equals(System.getProperty("tomcat.util.buf.StringCache.byte.enabled", "false")));
+ ("true".equals(System.getProperty("org.apache.tomcat.util.buf.StringCache.byte.enabled", "false")));
protected static boolean charEnabled =
- ("true".equals(System.getProperty("tomcat.util.buf.StringCache.char.enabled", "false")));
+ ("true".equals(System.getProperty("org.apache.tomcat.util.buf.StringCache.char.enabled", "false")));
protected static int trainThreshold =
- Integer.parseInt(System.getProperty("tomcat.util.buf.StringCache.trainThreshold", "20000"));
+ Integer.parseInt(System.getProperty("org.apache.tomcat.util.buf.StringCache.trainThreshold", "20000"));
protected static int cacheSize =
- Integer.parseInt(System.getProperty("tomcat.util.buf.StringCache.cacheSize", "200"));
+ Integer.parseInt(System.getProperty("org.apache.tomcat.util.buf.StringCache.cacheSize", "200"));
protected static int maxStringSize =
- Integer.parseInt(System.getProperty("tomcat.util.buf.StringCache.maxStringSize", "128"));
+ Integer.parseInt(System.getProperty("org.apache.tomcat.util.buf.StringCache.maxStringSize", "128"));
/**
Modified: trunk/java/org/apache/tomcat/util/http/ServerCookie.java
===================================================================
--- trunk/java/org/apache/tomcat/util/http/ServerCookie.java 2009-04-17 10:59:59 UTC (rev 1015)
+++ trunk/java/org/apache/tomcat/util/http/ServerCookie.java 2009-04-17 12:02:55 UTC (rev 1016)
@@ -76,8 +76,8 @@
/**
* If set to true, we parse cookies according to the servlet spec,
*/
- public static final boolean STRICT_SERVLET_COMPLIANCE =
- Boolean.valueOf(System.getProperty("org.apache.catalina.STRICT_SERVLET_COMPLIANCE", "false")).booleanValue();
+ public static final boolean VERSION_SWITCH =
+ Boolean.valueOf(System.getProperty("org.apache.tomcat.util.http.ServerCookie.VERSION_SWITCH", "true")).booleanValue();
// Note: Servlet Spec =< 2.5 only refers to Netscape and RFC2109,
@@ -391,7 +391,7 @@
buf.append('"');
buf.append(escapeDoubleQuotes(value,1,value.length()-1));
buf.append('"');
- } else if (allowVersionSwitch && (!STRICT_SERVLET_COMPLIANCE) && version==0 && !isToken2(value, literals)) {
+ } else if (allowVersionSwitch && VERSION_SWITCH && version==0 && !isToken2(value, literals)) {
buf.append('"');
buf.append(escapeDoubleQuotes(value,0,value.length()));
buf.append('"');
Modified: trunk/res/jboss/org/apache/catalina/startup/catalina.properties
===================================================================
--- trunk/res/jboss/org/apache/catalina/startup/catalina.properties 2009-04-17 10:59:59 UTC (rev 1015)
+++ trunk/res/jboss/org/apache/catalina/startup/catalina.properties 2009-04-17 12:02:55 UTC (rev 1016)
@@ -8,9 +8,10 @@
org.apache.catalina.core.StandardHost.deployOnStartup=false
org.apache.catalina.core.StandardHost.deployXML=false
org.apache.catalina.core.StandardHost.startChildren=false
+org.apache.tomcat.util.http.ServerCookie.VERSION_SWITCH=false
# String cache configuration.
-tomcat.util.buf.StringCache.byte.enabled=true
-#tomcat.util.buf.StringCache.char.enabled=true
-#tomcat.util.buf.StringCache.trainThreshold=500000
-#tomcat.util.buf.StringCache.cacheSize=5000
+org.apache.tomcat.util.buf.StringCache.byte.enabled=true
+#org.apache.tomcat.util.buf.StringCache.char.enabled=true
+#org.apache.tomcat.util.buf.StringCache.trainThreshold=500000
+#org.apache.tomcat.util.buf.StringCache.cacheSize=5000
Modified: trunk/webapps/docs/sysprops.xml
===================================================================
--- trunk/webapps/docs/sysprops.xml 2009-04-17 10:59:59 UTC (rev 1015)
+++ trunk/webapps/docs/sysprops.xml 2009-04-17 12:02:55 UTC (rev 1016)
@@ -67,30 +67,30 @@
<p>The URL for the catalina.properties configuration file.</p>
</property>
- <property name="tomcat.util.buf.StringCache.byte.enabled">
+ <property name="org.apache.tomcat.tomcat.util.buf.StringCache.byte.enabled">
<p>If <code>true</code>, the String cache is enabled for
<code>ByteChunk</code>. If not specified, the default value of
<code>false</code> will be used.</p>
</property>
- <property name="tomcat.util.buf.StringCache.char.enabled">
+ <property name="org.apache.tomcat.tomcat.util.buf.StringCache.char.enabled">
<p>If <code>true</code>, the String cache is enabled for
<code>CharChunk</code>. If not specified, the default value of
<code>false</code> will be used.</p>
</property>
- <property name="tomcat.util.buf.StringCache.trainThreshold">
+ <property name="org.apache.tomcat.tomcat.util.buf.StringCache.trainThreshold">
<p>The number of times <code>toString()</code> must be called before the
cache is activated. If not specified, the default value of
<code>20000</code> will be used.</p>
</property>
- <property name="tomcat.util.buf.StringCache.cacheSize">
+ <property name="org.apache.tomcat.tomcat.util.buf.StringCache.cacheSize">
<p>The size of the String cache. If not specified, the default value of
<code>200</code> will be used.</p>
</property>
- <property name="tomcat.util.buf.StringCache.maxStringSize">
+ <property name="org.apache.tomcat.tomcat.util.buf.StringCache.maxStringSize">
<p>The maximum length of String that will be cached. If not specified, the
default value of <code>128</code> will be used.</p>
</property>
@@ -120,6 +120,12 @@
the default value of <code>false</code> will be used.</p>
</property>
+ <property name="org.apache.tomcat.util. http.ServerCookie.VERSION_SWITCH">
+ <p>If using cookie values which have to be quoted to be valid and v0 cookies,
+ this will cause an automatic switch to v1 cookies. If not
+ specified, the default value of <code>true</code> will be used.</p>
+ </property>
+
</properties>
</section>
15 years
JBossWeb SVN: r1015 - in trunk/test: webapps/cookies and 1 other directory.
by jbossweb-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2009-04-17 06:59:59 -0400 (Fri, 17 Apr 2009)
New Revision: 1015
Modified:
trunk/test/java/org/jboss/web/cookies/CookiesTestCase.java
trunk/test/webapps/cookies/test.jsp
Log:
Add tests for JBAS-6766.
Modified: trunk/test/java/org/jboss/web/cookies/CookiesTestCase.java
===================================================================
--- trunk/test/java/org/jboss/web/cookies/CookiesTestCase.java 2009-04-17 10:58:35 UTC (rev 1014)
+++ trunk/test/java/org/jboss/web/cookies/CookiesTestCase.java 2009-04-17 10:59:59 UTC (rev 1015)
@@ -66,71 +66,79 @@
}
/* should create foo (bar) and a (b) */
- public void testTest1() { mytest(1, "foo=bar; a=b"); }
- public void testTest2() { mytest(2, "foo=bar;a=b"); }
- public void testTest3() { mytest(3, "foo=bar;a=b;"); }
- public void testTest4() { mytest(4, "foo=bar;a=b; "); }
- public void testTest5() { mytest(5, "foo=bar;a=b; ;"); }
+ public void testTest1() { readTest(1, "foo=bar; a=b"); }
+ public void testTest2() { readTest(2, "foo=bar;a=b"); }
+ public void testTest3() { readTest(3, "foo=bar;a=b;"); }
+ public void testTest4() { readTest(4, "foo=bar;a=b; "); }
+ public void testTest5() { readTest(5, "foo=bar;a=b; ;"); }
/* should create foo () and a (b) */
- public void testTest6() { mytest(6, "foo=;a=b; ;"); }
- public void testTest7() { mytest(7, "foo;a=b; ;"); }
+ public void testTest6() { readTest(6, "foo=;a=b; ;"); }
+ public void testTest7() { readTest(7, "foo;a=b; ;"); }
/* v1 create foo (bar) and a (b) */
- public void testTest8() { mytest(8, "$Version=1; foo=bar;a=b"); }
- public void testTest9() { mytest(9, "$Version=1;foo=bar;a=b; ; "); }
+ public void testTest8() { readTest(8, "$Version=1; foo=bar;a=b"); }
+ public void testTest9() { readTest(9, "$Version=1;foo=bar;a=b; ; "); }
/* v1 create foo () and a (b) */
- public void testTest10() { mytest(10, "$Version=1;foo=;a=b; ; "); }
- public void testTest11() { mytest(11, "$Version=1;foo= ;a=b; ; "); }
- public void testTest12() { mytest(12, "$Version=1;foo;a=b; ; "); }
+ public void testTest10() { readTest(10, "$Version=1;foo=;a=b; ; "); }
+ public void testTest11() { readTest(11, "$Version=1;foo= ;a=b; ; "); }
+ public void testTest12() { readTest(12, "$Version=1;foo;a=b; ; "); }
/* v1 create foo (bar) and a (b) */
- public void testTest13() { mytest(13, "$Version=1;foo=\"bar\";a=b; ; "); }
+ public void testTest13() { readTest(13, "$Version=1;foo=\"bar\";a=b; ; "); }
/* use domain */
- public void testTest14() { mytest(14, "$Version=1;foo=\"bar\";$Domain=apache.org;a=b"); }
- public void testTest15() { mytest(15, "$Version=1;foo=\"bar\";$Domain=apache.org;a=b;$Domain=yahoo.com"); }
+ public void testTest14() { readTest(14, "$Version=1;foo=\"bar\";$Domain=apache.org;a=b"); }
+ public void testTest15() { readTest(15, "$Version=1;foo=\"bar\";$Domain=apache.org;a=b;$Domain=yahoo.com"); }
/* rfc2965 */
- public void testTest16() { mytest(16, "$Version=1;foo=\"bar\";$Domain=apache.org;$Port=8080;a=b"); }
+ public void testTest16() { readTest(16, "$Version=1;foo=\"bar\";$Domain=apache.org;$Port=8080;a=b"); }
// make sure these never split into two cookies - JVK
- public void testTest17() { mytest(17, "$Version=1;foo=\"b\"ar\";$Domain=apache.org;$Port=8080;a=b"); }
- public void testTest18() { mytest(18, "$Version=1;foo=\"b\\\"ar\";$Domain=apache.org;$Port=8080;a=b"); }
- public void testTest19() { mytest(19, "$Version=1;foo=\"b'ar\";$Domain=apache.org;$Port=8080;a=b"); }
+ public void testTest17() { readTest(17, "$Version=1;foo=\"b\"ar\";$Domain=apache.org;$Port=8080;a=b"); }
+ public void testTest18() { readTest(18, "$Version=1;foo=\"b\\\"ar\";$Domain=apache.org;$Port=8080;a=b"); }
+ public void testTest19() { readTest(19, "$Version=1;foo=\"b'ar\";$Domain=apache.org;$Port=8080;a=b"); }
// JFC: sure it is "b" and not b'ar ?
- public void testTest20() { mytest(20, "$Version=1;foo=b'ar;$Domain=apache.org;$Port=8080;a=b"); }
+ public void testTest20() { readTest(20, "$Version=1;foo=b'ar;$Domain=apache.org;$Port=8080;a=b"); }
// Ends in quoted value
- public void testTest21() { mytest(21, "foo=bar;a=\"b\""); }
- public void testTest22() { mytest(22, "foo=bar;a=\"b\";"); }
+ public void testTest21() { readTest(21, "foo=bar;a=\"b\""); }
+ public void testTest22() { readTest(22, "foo=bar;a=\"b\";"); }
// Testing bad stuff
- public void testTest23() { mytest(23, "$Version=\"1\"; foo='bar'; $Path=/path; $Domain=\"localhost\""); }
+ public void testTest23() { readTest(23, "$Version=\"1\"; foo='bar'; $Path=/path; $Domain=\"localhost\""); }
// wrong, path should not have '/' JVK ???
- public void testTest24() { mytest(24, "$Version=1;foo=\"bar\";$Path=/examples;a=b; ; "); }
+ public void testTest24() { readTest(24, "$Version=1;foo=\"bar\";$Path=/examples;a=b; ; "); }
// Test name-only at the end of the header
- public void testTest25() { mytest(25, "foo;a=b;bar"); }
- public void testTest26() { mytest(26, "foo;a=b;bar;"); }
- public void testTest27() { mytest(27, "foo;a=b;bar "); }
- public void testTest28() { mytest(28, "foo;a=b;bar ;"); }
+ public void testTest25() { readTest(25, "foo;a=b;bar"); }
+ public void testTest26() { readTest(26, "foo;a=b;bar;"); }
+ public void testTest27() { readTest(27, "foo;a=b;bar "); }
+ public void testTest28() { readTest(28, "foo;a=b;bar ;"); }
// BUG -- the ' ' needs to be skipped.
- public void testTest29() { mytest(29, "foo;a=b; ;bar"); }
+ public void testTest29() { readTest(29, "foo;a=b; ;bar"); }
// BUG -- ';' needs skipping
- public void testTest30() { mytest(30, "foo;a=b;;bar"); }
- public void testTest31() { mytest(31, "foo;a=b; ;;bar=rab"); }
- public void testTest32() { mytest(32, "foo;a=b;; ;bar=rab"); }
+ public void testTest30() { readTest(30, "foo;a=b;;bar"); }
+ public void testTest31() { readTest(31, "foo;a=b; ;;bar=rab"); }
+ public void testTest32() { readTest(32, "foo;a=b;; ;bar=rab"); }
- public void testTest33() { mytest(33, "a=b;#;bar=rab"); }
- public void testTest34() { mytest(34, "a=b;;\\;bar=rab"); }
+ public void testTest33() { readTest(33, "a=b;#;bar=rab"); }
+ public void testTest34() { readTest(34, "a=b;;\\;bar=rab"); }
// Try all the separators of version1 in version0 cookie.
- public void testTest35() { mytest(35, "a=()<>@:\\\"/[]?={}\t; foo=bar; a=b"); }
+ public void testTest35() { readTest(35, "a=()<>@:\\\"/[]?={}\t; foo=bar; a=b"); }
// Just test the version.
- public void testTest36() { mytest(36, "$Version=1;foo=bar"); }
- public void testTest37() { mytest(37, "$Version=0;foo=bar"); }
+ public void testTest36() { readTest(36, "$Version=1;foo=bar"); }
+ public void testTest37() { readTest(37, "$Version=0;foo=bar"); }
- public void mytest(int test, String cookie) {
+ // JBAS-6766..
+ public void testTest38() { readTest(38, "a==:;foo=b=:ar"); }
+ public void testTest39() { readTest(39, "a=:;foo=b:ar"); }
+ public void testTest40() { readTest(40, "a==;foo=b=ar"); }
+ public void testTestW38() { writeTest(38); }
+ public void testTestW39() { writeTest(39); }
+ public void testTestW40() { writeTest(40); }
+
+ public void writeTest(int test) {
try {
- String result = Mytest(test, cookie);
+ String result = Mytest(test, null, false);
if (result != null)
fail(result);
} catch (Exception ex) {
@@ -138,7 +146,18 @@
fail("Test failed because of " + ex);
}
}
- public String Mytest(int test, String cookie) throws Exception {
+
+ public void readTest(int test, String cookie) {
+ try {
+ String result = Mytest(test, cookie, true);
+ if (result != null)
+ fail(result);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ fail("Test failed because of " + ex);
+ }
+ }
+ public String Mytest(int test, String cookie, boolean read) throws Exception {
Socket socket = new Socket("localhost", 8080);
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
@@ -147,8 +166,12 @@
writer.write("User-Agent: CookiesTestCase/1.0\r\n");
writer.write("Connection: Keep-Alive\r\n");
writer.write("TEST: " + test + "\r\n");
- writer.write("ACTION: READ\r\n");
- writer.write("Cookie: " + cookie + "\r\n");
+ if (read)
+ writer.write("ACTION: READ\r\n");
+ else
+ writer.write("ACTION: CREATE\r\n");
+ if (cookie != null)
+ writer.write("Cookie: " + cookie + "\r\n");
writer.write("\r\n");
writer.flush();
@@ -158,12 +181,11 @@
}
responseStatus = responseStatus.substring(responseStatus.indexOf(' ') + 1, responseStatus.indexOf(' ', responseStatus.indexOf(' ') + 1));
int status = Integer.parseInt(responseStatus);
- if (status != 200) {
- return "Error " + status + " from Servlet";
- }
+
// read all the headers.
String header = reader.readLine();
int contentLength = 0;
+ String error = "Unknown";
while (!"".equals(header)) {
int colon = header.indexOf(':');
String headerName = header.substring(0, colon).trim();
@@ -171,6 +193,9 @@
if ("content-length".equalsIgnoreCase(headerName)) {
contentLength = Integer.parseInt(headerValue);
}
+ if ("ERROR".equalsIgnoreCase(headerName)) {
+ error = headerValue;
+ }
header = reader.readLine();
}
if (contentLength > 0) {
@@ -185,6 +210,9 @@
}
}
}
+ if (status != 200) {
+ return "Error " + error + " from Servlet";
+ }
return null;
}
Modified: trunk/test/webapps/cookies/test.jsp
===================================================================
--- trunk/test/webapps/cookies/test.jsp 2009-04-17 10:58:35 UTC (rev 1014)
+++ trunk/test/webapps/cookies/test.jsp 2009-04-17 10:59:59 UTC (rev 1015)
@@ -12,11 +12,13 @@
*/
String test = request.getHeader("TEST");
String action = request.getHeader("ACTION");
- int ntest = Integer.parseInt(test);
+ int ntest = 0;
+ if (test != null)
+ ntest = Integer.parseInt(test);
response.setContentType("text/html; charset=UTF-8");
- if (action.compareTo("READ") == 0) {
+ if (action !=null && action.compareTo("READ") == 0) {
switch (ntest) {
case 1: test(response, request, out, "foo", "bar", "a", "b"); break;
case 2: test(response, request, out, "foo", "bar", "a", "b"); break;
@@ -73,15 +75,27 @@
case 36: test(response, request, out, 1); break;
case 37: test(response, request, out, 0); break;
- default: response.sendError(500, "Unknown test");break;
+ /* JBAS-6766...
+ case 38: test(response, request, out, "a", "=:", "foo", "b=:ar"); break;
+ case 39: test(response, request, out, "a", ":", "foo", "b:ar"); break;
+ case 40: test(response, request, out, "a", "=", "foo", "b=ar"); break;
+ */
+ case 38: test(response, request, out, "foo", "b"); break;
+ case 39: test(response, request, out, "foo", "b"); break;
+ case 40: test(response, request, out, "foo", "b"); break;
+
+ default: sendError(response, "Unknown test");break;
}
- } else if (action.compareTo("CREATE") == 0) {
+ } else if (action != null && action.compareTo("CREATE") == 0) {
switch (ntest) {
- case 1: out.println("OK");break;
- default: response.sendError(500, "Unknown test");break;
+ // case 1: out.println("OK");break;
+ case 38: test(response, out, "a", "=:", "foo", "b=:ar"); break;
+ case 39: test(response, out, "a", ":", "foo", "b:ar"); break;
+ case 40: test(response, out, "a", "=", "foo", "b=ar"); break;
+ default: sendError(response, "Unknown test");break;
}
} else {
- response.sendError(500, "Unknown command");
+ sendError(response, "Unknown command");
}
%>
</BODY>
@@ -91,7 +105,7 @@
Cookie[] cookies = request.getCookies();
if (cookies != null) {
if (cookies.length != 3) {
- response.sendError(500, "Wrong number of cookies");
+ sendError(response, "Wrong number of cookies (3:" + cookies.length + ")");
return;
}
if (name1.compareTo(cookies[0].getName()) == 0 &&
@@ -102,18 +116,18 @@
val3.compareTo(cookies[2].getValue()) == 0 )
out.println("OK");
else {
- response.sendError(500, "Value or name don't match");
+ sendError(response, "Value or name don't match");
return;
}
} else {
- response.sendError(500, "No cookies");
+ sendError(response, "No cookies");
}
}
void test(HttpServletResponse response, HttpServletRequest request, JspWriter out, String name1, String val1, String name2, String val2) throws Exception {
Cookie[] cookies = request.getCookies();
if (cookies != null) {
if (cookies.length != 2) {
- response.sendError(500, "Wrong number of cookies");
+ sendError(response, "Wrong number of cookies (2:" + cookies.length + ")");
return;
}
if (name1.compareTo(cookies[0].getName()) == 0 &&
@@ -122,18 +136,36 @@
val2.compareTo(cookies[1].getValue()) == 0)
out.println("OK");
else {
- response.sendError(500, "Value or name don't match");
+ sendError(response, "Value or name don't match");
return;
}
} else {
- response.sendError(500, "No cookies");
+ sendError(response, "No cookies");
}
}
+void test(HttpServletResponse response, HttpServletRequest request, JspWriter out, String name1, String val1) throws Exception {
+ Cookie[] cookies = request.getCookies();
+ if (cookies != null) {
+ if (cookies.length != 1) {
+ sendError(response, "Wrong number of cookies (1:" + cookies.length + ")");
+ return;
+ }
+ if (name1.compareTo(cookies[0].getName()) == 0 &&
+ val1.compareTo(cookies[0].getValue()) == 0 )
+ out.println("OK");
+ else {
+ sendError(response, "Value or name don't match (got " + cookies[0].getName() + ":" + cookies[0].getValue());
+ return;
+ }
+ } else {
+ sendError(response, "No cookies");
+ }
+ }
void test(HttpServletResponse response, HttpServletRequest request, JspWriter out) throws Exception {
Cookie[] cookies = request.getCookies();
if (cookies != null) {
if (cookies.length != 0) {
- response.sendError(500, "Wrong number of cookies");
+ sendError(response, "Wrong number of cookies (0:" + cookies.length + ")");
return;
}
}
@@ -149,5 +181,16 @@
}
}
}
- response.sendError(500, "Wrong number of cookies");
+ sendError(response, "Wrong number of cookies");
+ }
+void sendError(HttpServletResponse response, String mess) throws Exception {
+ response.setHeader("ERROR", mess);
+ response.sendError(500, mess);
+ }
+void test(HttpServletResponse response, JspWriter out, String name1, String val1, String name2, String val2) throws Exception {
+ Cookie cookie = new Cookie(name1, val1);
+ response.addCookie(cookie);
+ cookie = new Cookie(name2, val2);
+ response.addCookie(cookie);
+ out.println("OK");
}%>
15 years
JBossWeb SVN: r1014 - in branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache: tomcat/util/http and 1 other directory.
by jbossweb-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2009-04-17 06:58:35 -0400 (Fri, 17 Apr 2009)
New Revision: 1014
Modified:
branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/startup/catalina.properties
branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/tomcat/util/http/ServerCookie.java
Log:
Add org.apache.tomcat.util.http.ServerCookie.VERSION_SWITCH
Modified: branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/startup/catalina.properties
===================================================================
--- branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/startup/catalina.properties 2009-04-16 21:00:07 UTC (rev 1013)
+++ branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/startup/catalina.properties 2009-04-17 10:58:35 UTC (rev 1014)
@@ -64,3 +64,6 @@
#tomcat.util.buf.StringCache.char.enabled=true
#tomcat.util.buf.StringCache.trainThreshold=500000
#tomcat.util.buf.StringCache.cacheSize=5000
+
+# Allow to use Version 1 cookie (quoted cookie) when the cookie value contains a control character.
+org.apache.tomcat.util.http.ServerCookie.VERSION_SWITCH=true
Modified: branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/tomcat/util/http/ServerCookie.java
===================================================================
--- branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/tomcat/util/http/ServerCookie.java 2009-04-16 21:00:07 UTC (rev 1013)
+++ branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/tomcat/util/http/ServerCookie.java 2009-04-17 10:58:35 UTC (rev 1014)
@@ -57,8 +57,8 @@
/**
* If set to true, we parse cookies according to the servlet spec,
*/
- public static final boolean STRICT_SERVLET_COMPLIANCE =
- Boolean.valueOf(System.getProperty("org.apache.catalina.STRICT_SERVLET_COMPLIANCE", "false")).booleanValue();
+ public static final boolean VERSION_SWITCH =
+ Boolean.valueOf(System.getProperty("org.apache.tomcat.util.http.ServerCookie.VERSION_SWITCH", "false")).booleanValue();
// Note: Servlet Spec =< 2.5 only refers to Netscape and RFC2109,
@@ -370,7 +370,7 @@
buf.append('"');
buf.append(escapeDoubleQuotes(value,1,value.length()-1));
buf.append('"');
- } else if (allowVersionSwitch && (!STRICT_SERVLET_COMPLIANCE) && version==0 && !isToken2(value, literals)) {
+ } else if (allowVersionSwitch && VERSION_SWITCH && version==0 && !isToken2(value, literals)) {
buf.append('"');
buf.append(escapeDoubleQuotes(value,0,value.length()));
buf.append('"');
15 years
JBossWeb SVN: r1013 - trunk.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-04-16 17:00:07 -0400 (Thu, 16 Apr 2009)
New Revision: 1013
Modified:
trunk/PATCHES.txt
Log:
- Big nonsense upstream. As usual these days ...
Modified: trunk/PATCHES.txt
===================================================================
--- trunk/PATCHES.txt 2009-04-16 16:45:25 UTC (rev 1012)
+++ trunk/PATCHES.txt 2009-04-16 21:00:07 UTC (rev 1013)
@@ -61,3 +61,6 @@
763654
Specific hack to address some error condition in HTTP method
+
+765727
+ETag should be identical regardless of how the entity is encoded, this patch "fixes" apparently broken proxies
15 years
JBossWeb SVN: r1012 - in trunk/test: webapps/cookies and 1 other directory.
by jbossweb-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2009-04-16 12:45:25 -0400 (Thu, 16 Apr 2009)
New Revision: 1012
Modified:
trunk/test/java/org/jboss/web/cookies/CookiesTestCase.java
trunk/test/webapps/cookies/test.jsp
Log:
READ is the servlet read a check the cookies.
CREATE it creates the cookies and the client check them.
Modified: trunk/test/java/org/jboss/web/cookies/CookiesTestCase.java
===================================================================
--- trunk/test/java/org/jboss/web/cookies/CookiesTestCase.java 2009-04-16 16:31:35 UTC (rev 1011)
+++ trunk/test/java/org/jboss/web/cookies/CookiesTestCase.java 2009-04-16 16:45:25 UTC (rev 1012)
@@ -147,7 +147,7 @@
writer.write("User-Agent: CookiesTestCase/1.0\r\n");
writer.write("Connection: Keep-Alive\r\n");
writer.write("TEST: " + test + "\r\n");
- writer.write("ACTION: CREATE\r\n");
+ writer.write("ACTION: READ\r\n");
writer.write("Cookie: " + cookie + "\r\n");
writer.write("\r\n");
writer.flush();
Modified: trunk/test/webapps/cookies/test.jsp
===================================================================
--- trunk/test/webapps/cookies/test.jsp 2009-04-16 16:31:35 UTC (rev 1011)
+++ trunk/test/webapps/cookies/test.jsp 2009-04-16 16:45:25 UTC (rev 1012)
@@ -16,7 +16,7 @@
response.setContentType("text/html; charset=UTF-8");
- if (action.compareTo("CREATE") == 0) {
+ if (action.compareTo("READ") == 0) {
switch (ntest) {
case 1: test(response, request, out, "foo", "bar", "a", "b"); break;
case 2: test(response, request, out, "foo", "bar", "a", "b"); break;
@@ -75,7 +75,7 @@
default: response.sendError(500, "Unknown test");break;
}
- } else if (action.compareTo("READ") == 0) {
+ } else if (action.compareTo("CREATE") == 0) {
switch (ntest) {
case 1: out.println("OK");break;
default: response.sendError(500, "Unknown test");break;
15 years
JBossWeb SVN: r1011 - in trunk/test: java/org/jboss/web and 3 other directories.
by jbossweb-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2009-04-16 12:31:35 -0400 (Thu, 16 Apr 2009)
New Revision: 1011
Added:
trunk/test/build.properties.default
trunk/test/build.xml
trunk/test/java/org/jboss/web/cookies/
trunk/test/java/org/jboss/web/cookies/CookiesTestCase.java
trunk/test/webapps/cookies/
trunk/test/webapps/cookies/test.jsp
Log:
Add some tests for the cookie fixes.
Added: trunk/test/build.properties.default
===================================================================
--- trunk/test/build.properties.default (rev 0)
+++ trunk/test/build.properties.default 2009-04-16 16:31:35 UTC (rev 1011)
@@ -0,0 +1,5 @@
+# junit stuff
+junit.version=4.5
+junit.jar.loc=http://kent.dl.sourceforge.net/sourceforge/junit/junit-${junit.version}.jar
+junit.jar=${base.path}/junit-${junit.version}/junit-${junit.version}.jar
+base-junit.home=${base.path}/junit-${junit.version}
Added: trunk/test/build.xml
===================================================================
--- trunk/test/build.xml (rev 0)
+++ trunk/test/build.xml 2009-04-16 16:31:35 UTC (rev 1011)
@@ -0,0 +1,116 @@
+<?xml version="1.0"?>
+<!--
+ * Copyright(c) 2009 Red Hat Middleware, LLC,
+ * and individual contributors as indicated by the @authors tag.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library in the file COPYING.LIB;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * @author Jean-Frederic Clere
+ * @version $Revision$
+-->
+<project name="jbossweb_test" default="all" basedir=".">
+
+ <!-- See "build.properties.sample" in the top level directory for all -->
+ <!-- property values you must customize for successful building!!! -->
+ <property file="${user.home}/build.properties"/>
+ <property file="build.properties"/>
+
+ <property file="build.properties.default"/>
+
+ <property name="test.classes" value="${basedir}/output/classes"/>
+
+ <property name="compile.source" value="1.5"/>
+
+ <property name="test.runner" value="junit.textui.TestRunner"/>
+
+ <path id="jbossweb.test.classpath">
+ <pathelement location="${test.classes}"/>
+ <pathelement location="${junit.jar}"/>
+ </path>
+
+ <target name="compile" depends="download">
+
+ <mkdir dir="${test.classes}"/>
+ <mkdir dir="${test.classes}/conf"/>
+
+ <!-- Compile -->
+ <javac srcdir="." destdir="${test.classes}"
+ debug="on" debuglevel="lines,vars,source"
+ deprecation="${compile.deprecation}"
+ source="${compile.source}"
+ optimize="${compile.optimize}">
+ <classpath refid="jbossweb.test.classpath" />
+ <include name="java/org/jboss/web/cookies/**" />
+ </javac>
+ </target>
+
+ <!-- Run the tests -->
+ <target name="all" depends="compile">
+ <java dir="${test.classes}" classname="${test.runner}" fork="yes">
+ <arg value="org.jboss.web.cookies.CookiesTestCase"/>
+ <jvmarg line="-Dcluster=${cluster}"/>
+ <classpath refid="jbossweb.test.classpath"/>
+ </java>
+ </target>
+
+ <!-- Download and dependency building -->
+ <target name="proxyflags">
+ <!-- check proxy parameters. -->
+ <condition property="useproxy">
+ <equals arg1="${proxy.use}" arg2="on" />
+ </condition>
+ </target>
+
+ <target name="setproxy" depends="proxyflags" if="useproxy">
+ <taskdef name="setproxy"
+ classname="org.apache.tools.ant.taskdefs.optional.net.SetProxy" />
+ <setproxy proxyhost="${proxy.host}" proxyport="${proxy.port}"
+ proxyuser="${proxy.user}" proxypassword="${proxy.password}" />
+ <echo message="Using ${proxy.host}:${proxy.port} to download ${sourcefile}"/>
+ </target>
+
+ <target name="testexist">
+ <echo message="Testing for ${destfile}"/>
+ <available file="${destfile}" property="exist"/>
+ </target>
+
+ <target name="downloadgz" unless="exist" depends="setproxy,testexist">
+ <!-- Download and extract the package -->
+ <mkdir dir="${base.path}" />
+ <get src="${sourcefile}" dest="${base.path}/file.tar.gz" />
+ <gunzip src="${base.path}/file.tar.gz" dest="${base.path}/file.tar"/>
+ <untar src="${base.path}/file.tar" dest="${base.path}"/>
+ <delete file="${base.path}/file.tar"/>
+ <delete file="${base.path}/file.tar.gz"/>
+ </target>
+
+ <target name="downloadfile" unless="exist" depends="setproxy,testexist">
+ <!-- Download extract the file -->
+ <mkdir dir="${destdir}" />
+ <get src="${sourcefile}" dest="${destfile}" />
+ </target>
+
+ <target name="download" description="Builds and download dependent components">
+ <antcall target="downloadfile">
+ <param name="sourcefile" value="${junit.jar.loc}"/>
+ <param name="destfile" value="${junit.jar}"/>
+ <param name="destdir" value="${base-junit.home}"/>
+ </antcall>
+ </target>
+
+</project>
Added: trunk/test/java/org/jboss/web/cookies/CookiesTestCase.java
===================================================================
--- trunk/test/java/org/jboss/web/cookies/CookiesTestCase.java (rev 0)
+++ trunk/test/java/org/jboss/web/cookies/CookiesTestCase.java 2009-04-16 16:31:35 UTC (rev 1011)
@@ -0,0 +1,191 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ * @author Jean-Frederic Clere
+ */
+
+
+package org.jboss.web.cookies;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.net.Socket;
+
+public class CookiesTestCase extends TestCase {
+
+ /**
+ * Construct a new instance of this test case.
+ *
+ * @param name Name of the test case
+ */
+ public CookiesTestCase(String name) {
+ super(name);
+ }
+
+ /**
+ * Set up instance variables required by this test case.
+ */
+ public void setUp() {
+ }
+
+ /**
+ * Return the tests included in this test suite.
+ */
+ public static Test suite() {
+ return (new TestSuite(CookiesTestCase.class));
+ }
+
+ /**
+ * Tear down instance variables required by this test case.
+ */
+ public void tearDown() {
+ }
+
+ /* should create foo (bar) and a (b) */
+ public void testTest1() { mytest(1, "foo=bar; a=b"); }
+ public void testTest2() { mytest(2, "foo=bar;a=b"); }
+ public void testTest3() { mytest(3, "foo=bar;a=b;"); }
+ public void testTest4() { mytest(4, "foo=bar;a=b; "); }
+ public void testTest5() { mytest(5, "foo=bar;a=b; ;"); }
+
+ /* should create foo () and a (b) */
+ public void testTest6() { mytest(6, "foo=;a=b; ;"); }
+ public void testTest7() { mytest(7, "foo;a=b; ;"); }
+
+ /* v1 create foo (bar) and a (b) */
+ public void testTest8() { mytest(8, "$Version=1; foo=bar;a=b"); }
+ public void testTest9() { mytest(9, "$Version=1;foo=bar;a=b; ; "); }
+ /* v1 create foo () and a (b) */
+ public void testTest10() { mytest(10, "$Version=1;foo=;a=b; ; "); }
+ public void testTest11() { mytest(11, "$Version=1;foo= ;a=b; ; "); }
+ public void testTest12() { mytest(12, "$Version=1;foo;a=b; ; "); }
+
+ /* v1 create foo (bar) and a (b) */
+ public void testTest13() { mytest(13, "$Version=1;foo=\"bar\";a=b; ; "); }
+ /* use domain */
+ public void testTest14() { mytest(14, "$Version=1;foo=\"bar\";$Domain=apache.org;a=b"); }
+ public void testTest15() { mytest(15, "$Version=1;foo=\"bar\";$Domain=apache.org;a=b;$Domain=yahoo.com"); }
+ /* rfc2965 */
+ public void testTest16() { mytest(16, "$Version=1;foo=\"bar\";$Domain=apache.org;$Port=8080;a=b"); }
+ // make sure these never split into two cookies - JVK
+ public void testTest17() { mytest(17, "$Version=1;foo=\"b\"ar\";$Domain=apache.org;$Port=8080;a=b"); }
+ public void testTest18() { mytest(18, "$Version=1;foo=\"b\\\"ar\";$Domain=apache.org;$Port=8080;a=b"); }
+ public void testTest19() { mytest(19, "$Version=1;foo=\"b'ar\";$Domain=apache.org;$Port=8080;a=b"); }
+ // JFC: sure it is "b" and not b'ar ?
+ public void testTest20() { mytest(20, "$Version=1;foo=b'ar;$Domain=apache.org;$Port=8080;a=b"); }
+ // Ends in quoted value
+ public void testTest21() { mytest(21, "foo=bar;a=\"b\""); }
+ public void testTest22() { mytest(22, "foo=bar;a=\"b\";"); }
+
+ // Testing bad stuff
+ public void testTest23() { mytest(23, "$Version=\"1\"; foo='bar'; $Path=/path; $Domain=\"localhost\""); }
+
+ // wrong, path should not have '/' JVK ???
+ public void testTest24() { mytest(24, "$Version=1;foo=\"bar\";$Path=/examples;a=b; ; "); }
+ // Test name-only at the end of the header
+ public void testTest25() { mytest(25, "foo;a=b;bar"); }
+ public void testTest26() { mytest(26, "foo;a=b;bar;"); }
+ public void testTest27() { mytest(27, "foo;a=b;bar "); }
+ public void testTest28() { mytest(28, "foo;a=b;bar ;"); }
+ // BUG -- the ' ' needs to be skipped.
+ public void testTest29() { mytest(29, "foo;a=b; ;bar"); }
+ // BUG -- ';' needs skipping
+ public void testTest30() { mytest(30, "foo;a=b;;bar"); }
+ public void testTest31() { mytest(31, "foo;a=b; ;;bar=rab"); }
+ public void testTest32() { mytest(32, "foo;a=b;; ;bar=rab"); }
+
+ public void testTest33() { mytest(33, "a=b;#;bar=rab"); }
+ public void testTest34() { mytest(34, "a=b;;\\;bar=rab"); }
+
+ // Try all the separators of version1 in version0 cookie.
+ public void testTest35() { mytest(35, "a=()<>@:\\\"/[]?={}\t; foo=bar; a=b"); }
+
+ // Just test the version.
+ public void testTest36() { mytest(36, "$Version=1;foo=bar"); }
+ public void testTest37() { mytest(37, "$Version=0;foo=bar"); }
+
+ public void mytest(int test, String cookie) {
+ try {
+ String result = Mytest(test, cookie);
+ if (result != null)
+ fail(result);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ fail("Test failed because of " + ex);
+ }
+ }
+ public String Mytest(int test, String cookie) throws Exception {
+ Socket socket = new Socket("localhost", 8080);
+ BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
+ BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
+ // writer.write("GET /cookies/test.jsp HTTP/1.0");
+ writer.write("GET /myapp/test.jsp HTTP/1.0\r\n");
+ writer.write("User-Agent: CookiesTestCase/1.0\r\n");
+ writer.write("Connection: Keep-Alive\r\n");
+ writer.write("TEST: " + test + "\r\n");
+ writer.write("ACTION: CREATE\r\n");
+ writer.write("Cookie: " + cookie + "\r\n");
+ writer.write("\r\n");
+ writer.flush();
+
+ String responseStatus = reader.readLine();
+ if (responseStatus == null) {
+ return "Can't read answer" ;
+ }
+ responseStatus = responseStatus.substring(responseStatus.indexOf(' ') + 1, responseStatus.indexOf(' ', responseStatus.indexOf(' ') + 1));
+ int status = Integer.parseInt(responseStatus);
+ if (status != 200) {
+ return "Error " + status + " from Servlet";
+ }
+ // read all the headers.
+ String header = reader.readLine();
+ int contentLength = 0;
+ while (!"".equals(header)) {
+ int colon = header.indexOf(':');
+ String headerName = header.substring(0, colon).trim();
+ String headerValue = header.substring(colon + 1).trim();
+ if ("content-length".equalsIgnoreCase(headerName)) {
+ contentLength = Integer.parseInt(headerValue);
+ }
+ header = reader.readLine();
+ }
+ if (contentLength > 0) {
+ char[] buf = new char[512];
+ while (contentLength > 0) {
+ int thisTime = (contentLength > buf.length) ? buf.length : contentLength;
+ int n = reader.read(buf, 0, thisTime);
+ if (n <= 0) {
+ return "Read content failed";
+ } else {
+ contentLength -= n;
+ }
+ }
+ }
+ return null;
+ }
+
+}
Added: trunk/test/webapps/cookies/test.jsp
===================================================================
--- trunk/test/webapps/cookies/test.jsp (rev 0)
+++ trunk/test/webapps/cookies/test.jsp 2009-04-16 16:31:35 UTC (rev 1011)
@@ -0,0 +1,153 @@
+<%@ page pageEncoding="UTF-8"%>
+<%@ page import="java.io.*"%>
+<HTML>
+<HEAD>
+<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<TITLE>cookies#test.</TITLE>
+</HEAD>
+<BODY>
+<%
+ /*
+ * Just read the header and process the corresponding tests
+ */
+ String test = request.getHeader("TEST");
+ String action = request.getHeader("ACTION");
+ int ntest = Integer.parseInt(test);
+
+ response.setContentType("text/html; charset=UTF-8");
+
+ if (action.compareTo("CREATE") == 0) {
+ switch (ntest) {
+ case 1: test(response, request, out, "foo", "bar", "a", "b"); break;
+ case 2: test(response, request, out, "foo", "bar", "a", "b"); break;
+ case 3: test(response, request, out, "foo", "bar", "a", "b"); break;
+ case 4: test(response, request, out, "foo", "bar", "a", "b"); break;
+ case 5: test(response, request, out, "foo", "bar", "a", "b"); break;
+
+ case 6: test(response, request, out, "foo", "", "a", "b"); break;
+ case 7: test(response, request, out, "foo", "", "a", "b"); break;
+
+ case 8: test(response, request, out, "foo", "bar", "a", "b"); break;
+ case 9: test(response, request, out, "foo", "bar", "a", "b"); break;
+
+ case 10: test(response, request, out, "foo", "", "a", "b"); break;
+ case 11: test(response, request, out, "foo", "", "a", "b"); break;
+ case 12: test(response, request, out, "foo", "", "a", "b"); break;
+
+ case 13: test(response, request, out, "foo", "bar", "a", "b"); break;
+
+ case 14: test(response, request, out, "foo", "bar", "a", "b"); break;
+ case 15: test(response, request, out, "foo", "bar", "a", "b"); break;
+
+ case 16: test(response, request, out, "foo", "bar", "a", "b"); break;
+
+ case 17: test(response, request, out, "foo", "b", "a", "b"); break;
+ case 18: test(response, request, out, "foo", "b\"ar", "a", "b"); break;
+ case 19: test(response, request, out, "foo", "b'ar", "a", "b"); break;
+
+ case 20: test(response, request, out, "foo", "b", "a", "b"); break;
+
+ case 21: test(response, request, out, "foo", "bar", "a", "b"); break;
+ case 22: test(response, request, out, "foo", "bar", "a", "b"); break;
+
+ case 23: test(response, request, out); break;
+
+ case 24: test(response, request, out, "foo", "bar", "a", "b"); break;
+
+ case 25: test(response, request, out, "foo", "", "a", "b", "bar", ""); break;
+ case 26: test(response, request, out, "foo", "", "a", "b", "bar", ""); break;
+ case 27: test(response, request, out, "foo", "", "a", "b", "bar", ""); break;
+ case 28: test(response, request, out, "foo", "", "a", "b", "bar", ""); break;
+
+ case 29: test(response, request, out, "foo", "", "a", "b", "bar", ""); break;
+ case 30: test(response, request, out, "foo", "", "a", "b", "bar", ""); break;
+ case 31: test(response, request, out, "foo", "", "a", "b", "bar", "rab"); break;
+ case 32: test(response, request, out, "foo", "", "a", "b", "bar", "rab"); break;
+
+ case 33: test(response, request, out, "a", "b", "#", "", "bar", "rab"); break;
+
+ case 34: test(response, request, out, "a", "b", "bar", "rab"); break;
+
+ case 35: test(response, request, out, "foo", "bar", "a", "b"); break;
+
+ case 36: test(response, request, out, 1); break;
+ case 37: test(response, request, out, 0); break;
+
+ default: response.sendError(500, "Unknown test");break;
+ }
+ } else if (action.compareTo("READ") == 0) {
+ switch (ntest) {
+ case 1: out.println("OK");break;
+ default: response.sendError(500, "Unknown test");break;
+ }
+ } else {
+ response.sendError(500, "Unknown command");
+ }
+%>
+</BODY>
+</HTML>
+<%!
+void test(HttpServletResponse response, HttpServletRequest request, JspWriter out, String name1, String val1, String name2, String val2, String name3, String val3) throws Exception {
+ Cookie[] cookies = request.getCookies();
+ if (cookies != null) {
+ if (cookies.length != 3) {
+ response.sendError(500, "Wrong number of cookies");
+ return;
+ }
+ if (name1.compareTo(cookies[0].getName()) == 0 &&
+ val1.compareTo(cookies[0].getValue()) == 0 &&
+ name2.compareTo(cookies[1].getName()) == 0 &&
+ val2.compareTo(cookies[1].getValue()) == 0 &&
+ name3.compareTo(cookies[2].getName()) == 0 &&
+ val3.compareTo(cookies[2].getValue()) == 0 )
+ out.println("OK");
+ else {
+ response.sendError(500, "Value or name don't match");
+ return;
+ }
+ } else {
+ response.sendError(500, "No cookies");
+ }
+ }
+void test(HttpServletResponse response, HttpServletRequest request, JspWriter out, String name1, String val1, String name2, String val2) throws Exception {
+ Cookie[] cookies = request.getCookies();
+ if (cookies != null) {
+ if (cookies.length != 2) {
+ response.sendError(500, "Wrong number of cookies");
+ return;
+ }
+ if (name1.compareTo(cookies[0].getName()) == 0 &&
+ val1.compareTo(cookies[0].getValue()) == 0 &&
+ name2.compareTo(cookies[1].getName()) == 0 &&
+ val2.compareTo(cookies[1].getValue()) == 0)
+ out.println("OK");
+ else {
+ response.sendError(500, "Value or name don't match");
+ return;
+ }
+ } else {
+ response.sendError(500, "No cookies");
+ }
+ }
+void test(HttpServletResponse response, HttpServletRequest request, JspWriter out) throws Exception {
+ Cookie[] cookies = request.getCookies();
+ if (cookies != null) {
+ if (cookies.length != 0) {
+ response.sendError(500, "Wrong number of cookies");
+ return;
+ }
+ }
+ out.println("OK");
+ }
+void test(HttpServletResponse response, HttpServletRequest request, JspWriter out, int version) throws Exception {
+ Cookie[] cookies = request.getCookies();
+ if (cookies != null) {
+ if (cookies.length == 1) {
+ if (cookies[0].getVersion() == version) {
+ out.println("OK");
+ return;
+ }
+ }
+ }
+ response.sendError(500, "Wrong number of cookies");
+ }%>
15 years
JBossWeb SVN: r1010 - in trunk/java/org/apache/catalina: startup and 1 other directory.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-04-16 12:22:37 -0400 (Thu, 16 Apr 2009)
New Revision: 1010
Modified:
trunk/java/org/apache/catalina/core/StandardContext.java
trunk/java/org/apache/catalina/startup/ContextConfig.java
Log:
- Move TLD processing to the right place (where it should handle scanning of the other stuff).
Modified: trunk/java/org/apache/catalina/core/StandardContext.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardContext.java 2009-04-16 16:11:07 UTC (rev 1009)
+++ trunk/java/org/apache/catalina/core/StandardContext.java 2009-04-16 16:22:37 UTC (rev 1010)
@@ -25,7 +25,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
-import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.EventListener;
@@ -94,7 +93,6 @@
import org.apache.catalina.loader.WebappLoader;
import org.apache.catalina.session.StandardManager;
import org.apache.catalina.startup.ContextConfig;
-import org.apache.catalina.startup.TldConfig;
import org.apache.catalina.util.CharsetMapper;
import org.apache.catalina.util.ExtensionValidator;
import org.apache.catalina.util.RequestUtil;
@@ -4030,10 +4028,6 @@
((Lifecycle) pipeline).start();
}
- if(getProcessTlds()) {
- processTlds();
- }
-
// Notify our interested LifecycleListeners
lifecycle.fireLifecycleEvent(START_EVENT, null);
@@ -4236,41 +4230,6 @@
}
/**
- * Processes TLDs.
- *
- * @throws LifecycleException If an error occurs
- */
- protected void processTlds() throws LifecycleException {
- TldConfig tldConfig = new TldConfig();
- tldConfig.setContext(this);
-
- // (1) check if the attribute has been defined
- // on the context element.
- tldConfig.setTldValidation(tldValidation);
- tldConfig.setTldNamespaceAware(tldNamespaceAware);
-
- // (2) if the attribute wasn't defined on the context
- // try the host.
- if (!tldValidation) {
- tldConfig.setTldValidation
- (((StandardHost) getParent()).getXmlValidation());
- }
-
- if (!tldNamespaceAware) {
- tldConfig.setTldNamespaceAware
- (((StandardHost) getParent()).getXmlNamespaceAware());
- }
-
- try {
- tldConfig.execute();
- } catch (Exception ex) {
- log.error("Error reading tld listeners "
- + ex.toString(), ex);
- }
- }
-
-
- /**
* Stop this Context component.
*
* @exception LifecycleException if a shutdown error occurs
@@ -5369,23 +5328,8 @@
return tldValidation;
}
- /**
- * Sets the process TLDs attribute.
- *
- * @param newProcessTlds The new value
- */
- public void setProcessTlds(boolean newProcessTlds) {
- processTlds = newProcessTlds;
- }
/**
- * Returns the processTlds attribute value.
- */
- public boolean getProcessTlds() {
- return processTlds;
- }
-
- /**
* Get the server.xml <host> attribute's xmlNamespaceAware.
* @return true if namespace awarenes is enabled.
*/
Modified: trunk/java/org/apache/catalina/startup/ContextConfig.java
===================================================================
--- trunk/java/org/apache/catalina/startup/ContextConfig.java 2009-04-16 16:11:07 UTC (rev 1009)
+++ trunk/java/org/apache/catalina/startup/ContextConfig.java 2009-04-16 16:22:37 UTC (rev 1010)
@@ -485,7 +485,7 @@
* Set up an Authenticator automatically if required, and one has not
* already been configured.
*/
- protected synchronized void authenticatorConfig() {
+ protected void authenticatorConfig() {
// Does this Context require an Authenticator?
SecurityConstraint constraints[] = context.findConstraints();
@@ -795,7 +795,42 @@
}
}
+
+ /**
+ * Process additional descriptors: TLDs, web fragments, and map overlays.
+ */
+ // FIXME: Processing of web fragments
+ // FIXME: Map overlays
+ protected void applicationExtraDescriptorsConfig() {
+ TldConfig tldConfig = new TldConfig();
+ tldConfig.setContext(context);
+ // (1) check if the attribute has been defined
+ // on the context element.
+ tldConfig.setTldValidation(context.getTldValidation());
+ tldConfig.setTldNamespaceAware(context.getTldNamespaceAware());
+
+ // (2) if the attribute wasn't defined on the context
+ // try the host.
+ if (!context.getTldValidation()) {
+ tldConfig.setTldValidation
+ (((StandardHost) context.getParent()).getXmlValidation());
+ }
+
+ if (!context.getTldNamespaceAware()) {
+ tldConfig.setTldNamespaceAware
+ (((StandardHost) context.getParent()).getXmlNamespaceAware());
+ }
+
+ try {
+ tldConfig.execute();
+ } catch (Exception ex) {
+ log.error("Error reading tld listeners "
+ + ex.toString(), ex);
+ }
+ }
+
+
/**
* Process the default configuration file, if it exists.
*/
@@ -1102,7 +1137,7 @@
/**
* Process a "before start" event for this Context.
*/
- protected synchronized void beforeStart() {
+ protected void beforeStart() {
antiLocking();
}
@@ -1110,7 +1145,7 @@
/**
* Process a "start" event for this Context.
*/
- protected synchronized void start() {
+ protected void start() {
// Called from StandardContext.start()
if (log.isDebugEnabled())
@@ -1138,8 +1173,9 @@
}
// Process the default and application web.xml files
- // FIXME: Processing of web fragments
defaultWebConfig();
+ // FIXME: look where to place it according to the merging rules
+ applicationExtraDescriptorsConfig();
applicationWebConfig();
if (!context.getIgnoreAnnotations()) {
applicationAnnotationsConfig();
@@ -1181,7 +1217,7 @@
/**
* Process a "stop" event for this Context.
*/
- protected synchronized void stop() {
+ protected void stop() {
if (log.isDebugEnabled())
log.debug(sm.getString("contextConfig.stop"));
@@ -1347,7 +1383,7 @@
/**
* Process a "destroy" event for this Context.
*/
- protected synchronized void destroy() {
+ protected void destroy() {
// Called from StandardContext.destroy()
if (log.isDebugEnabled())
log.debug(sm.getString("contextConfig.destroy"));
15 years