This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 28aad28a317d262115fcc8afdd4d85e82cab51aa Author: Mark Thomas <ma...@apache.org> AuthorDate: Wed Sep 22 11:17:58 2021 +0100 Remove deprecated code from the Servlet API --- java/jakarta/servlet/ServletContext.java | 65 ----- java/jakarta/servlet/ServletRequest.java | 9 - java/jakarta/servlet/ServletRequestWrapper.java | 12 - java/jakarta/servlet/SingleThreadModel.java | 43 ---- java/jakarta/servlet/UnavailableException.java | 60 ----- java/jakarta/servlet/http/HttpServletRequest.java | 8 - .../servlet/http/HttpServletRequestWrapper.java | 12 - java/jakarta/servlet/http/HttpServletResponse.java | 36 --- .../servlet/http/HttpServletResponseWrapper.java | 36 --- java/jakarta/servlet/http/HttpSession.java | 57 ----- java/jakarta/servlet/http/HttpSessionContext.java | 53 ---- java/jakarta/servlet/http/HttpUtils.java | 281 --------------------- webapps/docs/changelog.xml | 4 + 13 files changed, 4 insertions(+), 672 deletions(-) diff --git a/java/jakarta/servlet/ServletContext.java b/java/jakarta/servlet/ServletContext.java index 301a3e0..fcac8be 100644 --- a/java/jakarta/servlet/ServletContext.java +++ b/java/jakarta/servlet/ServletContext.java @@ -299,57 +299,6 @@ public interface ServletContext { public RequestDispatcher getNamedDispatcher(String name); /** - * Do not use. This method was originally defined to retrieve a servlet from - * a <code>ServletContext</code>. In this version, this method always - * returns <code>null</code> and remains only to preserve binary - * compatibility. This method will be permanently removed in a future - * version of the Java Servlet API. - * <p> - * In lieu of this method, servlets can share information using the - * <code>ServletContext</code> class and can perform shared business logic - * by invoking methods on common non-servlet classes. - * - * @param name Not used - * - * @return Always <code>null</code> - * - * @throws ServletException never - * - * @deprecated As of Java Servlet API 2.1, with no direct replacement. - */ - @Deprecated - public Servlet getServlet(String name) throws ServletException; - - /** - * Do not use. This method was originally defined to return an - * <code>Enumeration</code> of all the servlets known to this servlet - * context. In this version, this method always returns an empty enumeration - * and remains only to preserve binary compatibility. This method will be - * permanently removed in a future version of the Java Servlet API. - * - * @return Always and empty Enumeration - * - * @deprecated As of Java Servlet API 2.0, with no replacement. - */ - @Deprecated - public Enumeration<Servlet> getServlets(); - - /** - * Do not use. This method was originally defined to return an - * <code>Enumeration</code> of all the servlet names known to this context. - * In this version, this method always returns an empty - * <code>Enumeration</code> and remains only to preserve binary - * compatibility. This method will be permanently removed in a future - * version of the Java Servlet API. - * - * @return Always and empty Enumeration - * - * @deprecated As of Java Servlet API 2.1, with no replacement. - */ - @Deprecated - public Enumeration<String> getServletNames(); - - /** * Writes the specified message to a servlet log file, usually an event log. * The name and type of the servlet log file is specific to the servlet * container. @@ -361,20 +310,6 @@ public interface ServletContext { public void log(String msg); /** - * Do not use. - * @param exception The exception to log - * @param msg The message to log with the exception - * @deprecated As of Java Servlet API 2.1, use - * {@link #log(String message, Throwable throwable)} instead. - * <p> - * This method was originally defined to write an exception's - * stack trace and an explanatory error message to the servlet - * log file. - */ - @Deprecated - public void log(Exception exception, String msg); - - /** * Writes an explanatory message and a stack trace for a given * <code>Throwable</code> exception to the servlet log file. The name and * type of the servlet log file is specific to the servlet container, diff --git a/java/jakarta/servlet/ServletRequest.java b/java/jakarta/servlet/ServletRequest.java index 1d0bbdd..4bb3206 100644 --- a/java/jakarta/servlet/ServletRequest.java +++ b/java/jakarta/servlet/ServletRequest.java @@ -404,15 +404,6 @@ public interface ServletRequest { public RequestDispatcher getRequestDispatcher(String path); /** - * @param path The virtual path to be converted to a real path - * @return {@link ServletContext#getRealPath(String)} - * @deprecated As of Version 2.1 of the Java Servlet API, use - * {@link ServletContext#getRealPath} instead. - */ - @Deprecated - public String getRealPath(String path); - - /** * Returns the Internet Protocol (IP) source port of the client or last * proxy that sent the request. * diff --git a/java/jakarta/servlet/ServletRequestWrapper.java b/java/jakarta/servlet/ServletRequestWrapper.java index 67ec408..fb5bcf7 100644 --- a/java/jakarta/servlet/ServletRequestWrapper.java +++ b/java/jakarta/servlet/ServletRequestWrapper.java @@ -303,18 +303,6 @@ public class ServletRequestWrapper implements ServletRequest { } /** - * The default behavior of this method is to return getRealPath(String path) - * on the wrapped request object. - * - * @deprecated As of Version 3.0 of the Java Servlet API - */ - @Override - @Deprecated - public String getRealPath(String path) { - return this.request.getRealPath(path); - } - - /** * The default behavior of this method is to return getRemotePort() on the * wrapped request object. * diff --git a/java/jakarta/servlet/SingleThreadModel.java b/java/jakarta/servlet/SingleThreadModel.java deleted file mode 100644 index 26e8caa..0000000 --- a/java/jakarta/servlet/SingleThreadModel.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package jakarta.servlet; - -/** - * Ensures that servlets handle only one request at a time. This interface has - * no methods. - * <p> - * If a servlet implements this interface, you are <i>guaranteed</i> that no two - * threads will execute concurrently in the servlet's <code>service</code> - * method. The servlet container can make this guarantee by synchronizing access - * to a single instance of the servlet, or by maintaining a pool of servlet - * instances and dispatching each new request to a free servlet. - * <p> - * Note that SingleThreadModel does not solve all thread safety issues. For - * example, session attributes and static variables can still be accessed by - * multiple requests on multiple threads at the same time, even when - * SingleThreadModel servlets are used. It is recommended that a developer take - * other means to resolve those issues instead of implementing this interface, - * such as avoiding the usage of an instance variable or synchronizing the block - * of the code accessing those resources. This interface is deprecated in - * Servlet API version 2.4. - * - * @deprecated As of Java Servlet API 2.4, with no direct replacement. - */ -@Deprecated -public interface SingleThreadModel { - // No methods -} diff --git a/java/jakarta/servlet/UnavailableException.java b/java/jakarta/servlet/UnavailableException.java index 73132ee..2f9073b 100644 --- a/java/jakarta/servlet/UnavailableException.java +++ b/java/jakarta/servlet/UnavailableException.java @@ -43,11 +43,6 @@ public class UnavailableException extends ServletException { private static final long serialVersionUID = 1L; /** - * The Servlet that is unavailable. - */ - private final Servlet servlet; - - /** * Is the issue permanent - i.e. is administrator action required? */ private final boolean permanent; @@ -58,47 +53,6 @@ public class UnavailableException extends ServletException { private final int seconds; /** - * @param servlet - * the <code>Servlet</code> instance that is unavailable - * @param msg - * a <code>String</code> specifying the descriptive message - * @deprecated As of Java Servlet API 2.2, use - * {@link #UnavailableException(String)} instead. - */ - @Deprecated - public UnavailableException(Servlet servlet, String msg) { - super(msg); - this.servlet = servlet; - permanent = true; - this.seconds = 0; - } - - /** - * @param seconds - * an integer specifying the number of seconds the servlet - * expects to be unavailable; if zero or negative, indicates that - * the servlet can't make an estimate - * @param servlet - * the <code>Servlet</code> that is unavailable - * @param msg - * a <code>String</code> specifying the descriptive message, - * which can be written to a log file or displayed for the user. - * @deprecated As of Java Servlet API 2.2, use - * {@link #UnavailableException(String, int)} instead. - */ - @Deprecated - public UnavailableException(int seconds, Servlet servlet, String msg) { - super(msg); - this.servlet = servlet; - if (seconds <= 0) { - this.seconds = -1; - } else { - this.seconds = seconds; - } - permanent = false; - } - - /** * Constructs a new exception with a descriptive message indicating that the * servlet is permanently unavailable. * @@ -108,7 +62,6 @@ public class UnavailableException extends ServletException { public UnavailableException(String msg) { super(msg); seconds = 0; - servlet = null; permanent = true; } @@ -139,7 +92,6 @@ public class UnavailableException extends ServletException { } else { this.seconds = seconds; } - servlet = null; permanent = false; } @@ -157,18 +109,6 @@ public class UnavailableException extends ServletException { } /** - * Returns the servlet that is reporting its unavailability. - * - * @return the <code>Servlet</code> object that is throwing the - * <code>UnavailableException</code> - * @deprecated As of Java Servlet API 2.2, with no replacement. - */ - @Deprecated - public Servlet getServlet() { - return servlet; - } - - /** * Returns the number of seconds the servlet expects to be temporarily * unavailable. * <p> diff --git a/java/jakarta/servlet/http/HttpServletRequest.java b/java/jakarta/servlet/http/HttpServletRequest.java index 1984299..1bd2bcb 100644 --- a/java/jakarta/servlet/http/HttpServletRequest.java +++ b/java/jakarta/servlet/http/HttpServletRequest.java @@ -473,14 +473,6 @@ public interface HttpServletRequest extends ServletRequest { public boolean isRequestedSessionIdFromURL(); /** - * @return {@link #isRequestedSessionIdFromURL()} - * @deprecated As of Version 2.1 of the Java Servlet API, use - * {@link #isRequestedSessionIdFromURL} instead. - */ - @Deprecated - public boolean isRequestedSessionIdFromUrl(); - - /** * Triggers the same authentication process as would be triggered if the * request is for a resource that is protected by a security constraint. * diff --git a/java/jakarta/servlet/http/HttpServletRequestWrapper.java b/java/jakarta/servlet/http/HttpServletRequestWrapper.java index 12f54c1..1125561 100644 --- a/java/jakarta/servlet/http/HttpServletRequestWrapper.java +++ b/java/jakarta/servlet/http/HttpServletRequestWrapper.java @@ -290,18 +290,6 @@ public class HttpServletRequestWrapper extends ServletRequestWrapper implements } /** - * The default behavior of this method is to return - * isRequestedSessionIdFromUrl() on the wrapped request object. - * - * @deprecated As of Version 3.0 of the Java Servlet API - */ - @Override - @Deprecated - public boolean isRequestedSessionIdFromUrl() { - return this._getHttpServletRequest().isRequestedSessionIdFromUrl(); - } - - /** * {@inheritDoc} * <p> * The default behavior of this method is to return diff --git a/java/jakarta/servlet/http/HttpServletResponse.java b/java/jakarta/servlet/http/HttpServletResponse.java index 4fb5538..479e75a 100644 --- a/java/jakarta/servlet/http/HttpServletResponse.java +++ b/java/jakarta/servlet/http/HttpServletResponse.java @@ -91,31 +91,10 @@ public interface HttpServletResponse extends ServletResponse { * @return the encoded URL if encoding is needed; the unchanged URL * otherwise. * @see #sendRedirect - * @see #encodeUrl */ public String encodeRedirectURL(String url); /** - * @param url - * the url to be encoded. - * @return the encoded URL if encoding is needed; the unchanged URL - * otherwise. - * @deprecated As of version 2.1, use encodeURL(String url) instead - */ - @Deprecated - public String encodeUrl(String url); - - /** - * @param url - * the url to be encoded. - * @return the encoded URL if encoding is needed; the unchanged URL - * otherwise. - * @deprecated As of version 2.1, use encodeRedirectURL(String url) instead - */ - @Deprecated - public String encodeRedirectUrl(String url); - - /** * Sends an error response to the client using the specified status code and * clears the output buffer. The server defaults to creating the response to * look like an HTML-formatted server error page containing the specified @@ -280,21 +259,6 @@ public interface HttpServletResponse extends ServletResponse { public void setStatus(int sc); /** - * Sets the status code and message for this response. - * - * @param sc - * the status code - * @param sm - * the status message - * @deprecated As of version 2.1, due to ambiguous meaning of the message - * parameter. To set a status code use - * <code>setStatus(int)</code>, to send an error with a - * description use <code>sendError(int, String)</code>. - */ - @Deprecated - public void setStatus(int sc, String sm); - - /** * Get the HTTP status code for this Response. * * @return The HTTP status code for this Response diff --git a/java/jakarta/servlet/http/HttpServletResponseWrapper.java b/java/jakarta/servlet/http/HttpServletResponseWrapper.java index 582a667..bc64609 100644 --- a/java/jakarta/servlet/http/HttpServletResponseWrapper.java +++ b/java/jakarta/servlet/http/HttpServletResponseWrapper.java @@ -88,30 +88,6 @@ public class HttpServletResponseWrapper extends ServletResponseWrapper } /** - * The default behavior of this method is to call encodeUrl(String url) on - * the wrapped response object. - * - * @deprecated As of Version 3.0 of the Java Servlet API - */ - @Override - @Deprecated - public String encodeUrl(String url) { - return this._getHttpServletResponse().encodeUrl(url); - } - - /** - * The default behavior of this method is to return encodeRedirectUrl(String - * url) on the wrapped response object. - * - * @deprecated As of Version 3.0 of the Java Servlet API - */ - @Override - @Deprecated - public String encodeRedirectUrl(String url) { - return this._getHttpServletResponse().encodeRedirectUrl(url); - } - - /** * The default behavior of this method is to call sendError(int sc, String * msg) on the wrapped response object. */ @@ -202,18 +178,6 @@ public class HttpServletResponseWrapper extends ServletResponseWrapper } /** - * The default behavior of this method is to call setStatus(int sc, String - * sm) on the wrapped response object. - * - * @deprecated As of Version 3.0 of the Java Servlet API - */ - @Override - @Deprecated - public void setStatus(int sc, String sm) { - this._getHttpServletResponse().setStatus(sc, sm); - } - - /** * {@inheritDoc} * <p> * The default implementation is to call diff --git a/java/jakarta/servlet/http/HttpSession.java b/java/jakarta/servlet/http/HttpSession.java index 9b03f0d..e712347 100644 --- a/java/jakarta/servlet/http/HttpSession.java +++ b/java/jakarta/servlet/http/HttpSession.java @@ -135,16 +135,6 @@ public interface HttpSession { public int getMaxInactiveInterval(); /** - * Do not use. - * @return A dummy implementation of HttpSessionContext - * @deprecated As of Version 2.1, this method is deprecated and has no - * replacement. It will be removed in a future version of the - * Java Servlet API. - */ - @Deprecated - public HttpSessionContext getSessionContext(); - - /** * Returns the object bound with the specified name in this session, or * <code>null</code> if no object is bound under the name. * @@ -157,18 +147,6 @@ public interface HttpSession { public Object getAttribute(String name); /** - * @param name - * a string specifying the name of the object - * @return the object with the specified name - * @exception IllegalStateException - * if this method is called on an invalidated session - * @deprecated As of Version 2.2, this method is replaced by - * {@link #getAttribute}. - */ - @Deprecated - public Object getValue(String name); - - /** * Returns an <code>Enumeration</code> of <code>String</code> objects * containing the names of all the objects bound to this session. * @@ -180,17 +158,6 @@ public interface HttpSession { public Enumeration<String> getAttributeNames(); /** - * @return an array of <code>String</code> objects specifying the names of - * all the objects bound to this session - * @exception IllegalStateException - * if this method is called on an invalidated session - * @deprecated As of Version 2.2, this method is replaced by - * {@link #getAttributeNames} - */ - @Deprecated - public String[] getValueNames(); - - /** * Binds an object to this session, using the name specified. If an object * of the same name is already bound to the session, the object is replaced. * <p> @@ -217,19 +184,6 @@ public interface HttpSession { public void setAttribute(String name, Object value); /** - * @param name - * the name to which the object is bound; cannot be null - * @param value - * the object to be bound; cannot be null - * @exception IllegalStateException - * if this method is called on an invalidated session - * @deprecated As of Version 2.2, this method is replaced by - * {@link #setAttribute} - */ - @Deprecated - public void putValue(String name, Object value); - - /** * Removes the object bound with the specified name from this session. If * the session does not have an object bound with the specified name, this * method does nothing. @@ -248,17 +202,6 @@ public interface HttpSession { public void removeAttribute(String name); /** - * @param name - * the name of the object to remove from this session - * @exception IllegalStateException - * if this method is called on an invalidated session - * @deprecated As of Version 2.2, this method is replaced by - * {@link #removeAttribute} - */ - @Deprecated - public void removeValue(String name); - - /** * Invalidates this session then unbinds any objects bound to it. * * @exception IllegalStateException diff --git a/java/jakarta/servlet/http/HttpSessionContext.java b/java/jakarta/servlet/http/HttpSessionContext.java deleted file mode 100644 index e54aa59..0000000 --- a/java/jakarta/servlet/http/HttpSessionContext.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package jakarta.servlet.http; - -import java.util.Enumeration; - -/** - * Do not use. - * @deprecated As of Java(tm) Servlet API 2.1 for security reasons, with no - * replacement. This interface will be removed in a future version - * of this API. - * @see HttpSession - * @see HttpSessionBindingEvent - * @see HttpSessionBindingListener - */ -@Deprecated -public interface HttpSessionContext { - - /** - * Do not use. - * @param sessionId Ignored - * @return Always <code>null</code> - * @deprecated As of Java Servlet API 2.1 with no replacement. This method - * must return null and will be removed in a future version of - * this API. - */ - @Deprecated - public HttpSession getSession(String sessionId); - - /** - * Do not use. - * @return Always an empty Enumeration - * @deprecated As of Java Servlet API 2.1 with no replacement. This method - * must return an empty <code>Enumeration</code> and will be - * removed in a future version of this API. - */ - @Deprecated - public Enumeration<String> getIds(); -} diff --git a/java/jakarta/servlet/http/HttpUtils.java b/java/jakarta/servlet/http/HttpUtils.java deleted file mode 100644 index b3d6bfd..0000000 --- a/java/jakarta/servlet/http/HttpUtils.java +++ /dev/null @@ -1,281 +0,0 @@ -/* -* Licensed to the Apache Software Foundation (ASF) under one or more -* contributor license agreements. See the NOTICE file distributed with -* this work for additional information regarding copyright ownership. -* The ASF licenses this file to You under the Apache License, Version 2.0 -* (the "License"); you may not use this file except in compliance with -* the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -package jakarta.servlet.http; - -import java.io.IOException; -import java.util.Arrays; -import java.util.Hashtable; -import java.util.ResourceBundle; -import java.util.StringTokenizer; - -import jakarta.servlet.ServletInputStream; - -/** - * @deprecated As of Java(tm) Servlet API 2.3. - * These methods were only useful - * with the default encoding and have been moved - * to the request interfaces. - */ -@Deprecated -public class HttpUtils { - - private static final String LSTRING_FILE = - "jakarta.servlet.http.LocalStrings"; - private static final ResourceBundle lStrings = - ResourceBundle.getBundle(LSTRING_FILE); - - - /** - * Constructs an empty <code>HttpUtils</code> object. - * - */ - public HttpUtils() { - // NOOP - } - - - /** - * - * Parses a query string passed from the client to the - * server and builds a <code>HashTable</code> object - * with key-value pairs. - * The query string should be in the form of a string - * packaged by the GET or POST method, that is, it - * should have key-value pairs in the form <i>key=value</i>, - * with each pair separated from the next by a & character. - * - * <p>A key can appear more than once in the query string - * with different values. However, the key appears only once in - * the hashtable, with its value being - * an array of strings containing the multiple values sent - * by the query string. - * - * <p>The keys and values in the hashtable are stored in their - * decoded form, so - * any + characters are converted to spaces, and characters - * sent in hexadecimal notation (like <i>%xx</i>) are - * converted to ASCII characters. - * - * @param s a string containing the query to be parsed - * - * @return a <code>HashTable</code> object built - * from the parsed key-value pairs - * - * @exception IllegalArgumentException if the query string - * is invalid - * - */ - public static Hashtable<String,String[]> parseQueryString(String s) { - - String valArray[] = null; - - if (s == null) { - throw new IllegalArgumentException(); - } - Hashtable<String,String[]> ht = new Hashtable<>(); - StringBuilder sb = new StringBuilder(); - StringTokenizer st = new StringTokenizer(s, "&"); - while (st.hasMoreTokens()) { - String pair = st.nextToken(); - int pos = pair.indexOf('='); - if (pos == -1) { - // XXX - // should give more detail about the illegal argument - throw new IllegalArgumentException(); - } - String key = parseName(pair.substring(0, pos), sb); - String val = parseName(pair.substring(pos+1), sb); - if (ht.containsKey(key)) { - String oldVals[] = ht.get(key); - valArray = Arrays.copyOf(oldVals, oldVals.length + 1); - valArray[oldVals.length] = val; - } else { - valArray = new String[1]; - valArray[0] = val; - } - ht.put(key, valArray); - } - return ht; - } - - - /** - * - * Parses data from an HTML form that the client sends to - * the server using the HTTP POST method and the - * <i>application/x-www-form-urlencoded</i> MIME type. - * - * <p>The data sent by the POST method contains key-value - * pairs. A key can appear more than once in the POST data - * with different values. However, the key appears only once in - * the hashtable, with its value being - * an array of strings containing the multiple values sent - * by the POST method. - * - * <p>The keys and values in the hashtable are stored in their - * decoded form, so - * any + characters are converted to spaces, and characters - * sent in hexadecimal notation (like <i>%xx</i>) are - * converted to ASCII characters. - * - * - * - * @param len an integer specifying the length, - * in characters, of the - * <code>ServletInputStream</code> - * object that is also passed to this - * method - * - * @param in the <code>ServletInputStream</code> - * object that contains the data sent - * from the client - * - * @return a <code>HashTable</code> object built - * from the parsed key-value pairs - * - * - * @exception IllegalArgumentException if the data - * sent by the POST method is invalid - * - */ - public static Hashtable<String,String[]> parsePostData(int len, - ServletInputStream in) { - // XXX - // should a length of 0 be an IllegalArgumentException - - // cheap hack to return an empty hash - if (len <= 0) { - return new Hashtable<>(); - } - - if (in == null) { - throw new IllegalArgumentException(); - } - - // Make sure we read the entire POSTed body. - byte[] postedBytes = new byte [len]; - try { - int offset = 0; - - do { - int inputLen = in.read (postedBytes, offset, len - offset); - if (inputLen <= 0) { - String msg = lStrings.getString("err.io.short_read"); - throw new IllegalArgumentException (msg); - } - offset += inputLen; - } while ((len - offset) > 0); - - } catch (IOException e) { - throw new IllegalArgumentException(e.getMessage(), e); - } - - // XXX we shouldn't assume that the only kind of POST body - // is FORM data encoded using ASCII or ISO Latin/1 ... or - // that the body should always be treated as FORM data. - try { - String postedBody = new String(postedBytes, 0, len, "8859_1"); - return parseQueryString(postedBody); - } catch (java.io.UnsupportedEncodingException e) { - // XXX function should accept an encoding parameter & throw this - // exception. Otherwise throw something expected. - throw new IllegalArgumentException(e.getMessage(), e); - } - } - - - /* - * Parse a name in the query string. - */ - private static String parseName(String s, StringBuilder sb) { - sb.setLength(0); - for (int i = 0; i < s.length(); i++) { - char c = s.charAt(i); - switch (c) { - case '+': - sb.append(' '); - break; - case '%': - try { - sb.append((char) Integer.parseInt(s.substring(i+1, i+3), - 16)); - i += 2; - } catch (NumberFormatException e) { - // XXX - // need to be more specific about illegal arg - throw new IllegalArgumentException(); - } catch (StringIndexOutOfBoundsException e) { - String rest = s.substring(i); - sb.append(rest); - if (rest.length() == 2) { - i++; - } - } - - break; - default: - sb.append(c); - break; - } - } - return sb.toString(); - } - - - /** - * - * Reconstructs the URL the client used to make the request, - * using information in the <code>HttpServletRequest</code> object. - * The returned URL contains a protocol, server name, port - * number, and server path, but it does not include query - * string parameters. - * - * <p>Because this method returns a <code>StringBuffer</code>, - * not a string, you can modify the URL easily, for example, - * to append query parameters. - * - * <p>This method is useful for creating redirect messages - * and for reporting errors. - * - * @param req a <code>HttpServletRequest</code> object - * containing the client's request - * - * @return a <code>StringBuffer</code> object containing - * the reconstructed URL - * - */ - public static StringBuffer getRequestURL (HttpServletRequest req) { - StringBuffer url = new StringBuffer (); - String scheme = req.getScheme (); - int port = req.getServerPort (); - String urlPath = req.getRequestURI(); - - url.append (scheme); // http, https - url.append ("://"); - url.append (req.getServerName ()); - if ((scheme.equals ("http") && port != 80) || (scheme.equals ("https") && port != 443)) { - url.append (':'); - url.append (req.getServerPort ()); - } - - url.append(urlPath); - return url; - } -} - - - diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 1345bce..e596cf1 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -115,6 +115,10 @@ Fix delete then create object manipulations with <code>DataSourceUserDatabase</code>. (remm) </fix> + <update> + Remove all deprecated code from the Servlet API to align Tomcat with + recent changes in the Jakarta Servlet specification project. (markt) + </update> </changelog> </subsection> <subsection name="Coyote"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org