patrickl 2002/08/01 10:20:36
Modified: coyote/src/java/org/apache/coyote Response.java
coyote/src/java/org/apache/coyote/tomcat4
CoyoteResponse.java
Log:
Servlet 2.4 spec says that ServletResponse now gets two more methods, (from sections 5.4,
14.2.22) Namely;
String getContentType();
void setCharacterEncoding(String charset)
Submitted by: Bob Herrmann (bob@jadn.com)
Revision Changes Path
1.12 +29 -0 jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/Response.java
Index: Response.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/Response.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- Response.java 9 Apr 2002 18:19:27 -0000 1.11
+++ Response.java 1 Aug 2002 17:20:36 -0000 1.12
@@ -443,6 +443,35 @@
}
+ /*
+ * Overrides the name of the character encoding used in the body
+ * of the request. This method must be called prior to reading
+ * request parameters or reading input using getReader().
+ *
+ * @param charset String containing the name of the chararacter encoding.
+ */
+ public void setCharacterEncoding(String charset) {
+
+ if (isCommitted())
+ return;
+
+ characterEncoding = charset;
+
+ String type = this.contentType;
+ int start = type.indexOf("charset=");
+ if ( start != -1 ) {
+ int end = type.indexOf(';', start+8);
+ if (end >= 0)
+ type = type.substring(0,start+8)
+ +charset+type.substring(end-1);
+ else
+ type = type.substring(0,start+8)
+ +charset;
+ this.contentType = type;
+
+ }
+ }
+
public String getCharacterEncoding() {
return characterEncoding;
}
1.19 +22 -4 jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat4/CoyoteResponse.java
Index: CoyoteResponse.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat4/CoyoteResponse.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- CoyoteResponse.java 28 Jun 2002 11:25:54 -0000 1.18
+++ CoyoteResponse.java 1 Aug 2002 17:20:36 -0000 1.19
@@ -717,6 +717,24 @@
}
+ /*
+ * Overrides the name of the character encoding used in the body
+ * of the request. This method must be called prior to reading
+ * request parameters or reading input using getReader().
+ *
+ * @param charset String containing the name of the chararacter encoding.
+ */
+ public void setCharacterEncoding(String charset) {
+
+ if (isCommitted())
+ return;
+
+ if (included)
+ return; // Ignore any call from an included servlet
+
+ coyoteResponse.setCharacterEncoding(charset);
+ }
+
/**
* Set the Locale that is appropriate for this response, including
* setting the appropriate character encoding.
--
To unsubscribe, e-mail: <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>
|