diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/view/SimpleContentViewHandler.java b/applications/content/src/main/java/org/apache/ofbiz/content/view/SimpleContentViewHandler.java index ac64679a11..dd29381ef7 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/view/SimpleContentViewHandler.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/view/SimpleContentViewHandler.java @@ -57,15 +57,10 @@ public class SimpleContentViewHandler extends AbstractViewHandler { public static final String module = SimpleContentViewHandler.class.getName(); private String rootDir = null; private String https = null; - private String defaultCharset = null; public void init(ServletContext context) throws ViewHandlerException { rootDir = context.getRealPath("/"); https = (String) context.getAttribute("https"); - defaultCharset = context.getInitParameter("charset"); - if (UtilValidate.isEmpty(defaultCharset)) { - defaultCharset = "UTF-8"; - } } /** * @see org.apache.ofbiz.webapp.view.ViewHandler#render(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) @@ -131,10 +126,10 @@ public class SimpleContentViewHandler extends AbstractViewHandler { // DEJ20080717: why are we rendering the DataResource directly instead of rendering the content? ByteBuffer byteBuffer = DataResourceWorker.getContentAsByteBuffer(delegator, dataResourceId, https, webSiteId, locale, rootDir); ByteArrayInputStream bais = new ByteArrayInputStream(byteBuffer.array()); - // setup chararcter encoding and content type + // setup character encoding and content type String charset = dataResource.getString("characterSetId"); if (UtilValidate.isEmpty(charset)) { - charset = defaultCharset; + charset = encoding; } if (UtilValidate.isEmpty(mimeTypeId)) { mimeTypeId = DataResourceWorker.getMimeType(dataResource); diff --git a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/WebAppUtil.java b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/WebAppUtil.java index 4496047c91..c9af72fc56 100644 --- a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/WebAppUtil.java +++ b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/WebAppUtil.java @@ -22,7 +22,6 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; -import java.io.UnsupportedEncodingException; import java.util.Map; import java.util.Map.Entry; import java.util.Set; @@ -144,17 +143,6 @@ public final class WebAppUtil { return dispatcher; } - public static void setCharacterEncoding(ServletRequest request) throws UnsupportedEncodingException { - String charset = request.getServletContext().getInitParameter("charset"); - if (UtilValidate.isEmpty(charset)) charset = request.getCharacterEncoding(); - if (UtilValidate.isEmpty(charset)) charset = "UTF-8"; - if (Debug.verboseOn()) Debug.logVerbose("The character encoding of the request is: [" + request.getCharacterEncoding() + "]. The character encoding we will use for the request is: [" + charset + "]", module); - - if (!"none".equals(charset)) { - request.setCharacterEncoding(charset); - } - } - public static void setAttributesFromRequestBody(ServletRequest request) { // read the body (for JSON requests) and set the parameters as attributes: Map requestBodyMap = null; diff --git a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/RequestHandler.java b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/RequestHandler.java index 3438fc2178..91c36a78c4 100644 --- a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/RequestHandler.java +++ b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/RequestHandler.java @@ -22,7 +22,6 @@ import static org.apache.ofbiz.base.util.UtilGenerics.checkMap; import java.io.IOException; import java.io.Serializable; -import java.io.UnsupportedEncodingException; import java.net.URL; import java.security.cert.X509Certificate; import java.util.Enumeration; @@ -41,7 +40,6 @@ import org.apache.ofbiz.base.util.Debug; import org.apache.ofbiz.base.util.SSLUtil; import org.apache.ofbiz.base.util.StringUtil; import org.apache.ofbiz.base.util.UtilCodec; -import org.apache.ofbiz.base.util.UtilFormatOut; import org.apache.ofbiz.base.util.UtilGenerics; import org.apache.ofbiz.base.util.UtilHttp; import org.apache.ofbiz.base.util.UtilMisc; @@ -76,7 +74,6 @@ public class RequestHandler { private final URL controllerConfigURL; private final boolean trackServerHit; private final boolean trackVisit; - private final String charset; public static RequestHandler getRequestHandler(ServletContext servletContext) { RequestHandler rh = (RequestHandler) servletContext.getAttribute("_REQUEST_HANDLER_"); @@ -101,7 +98,6 @@ public class RequestHandler { this.trackServerHit = !"false".equalsIgnoreCase(context.getInitParameter("track-serverhit")); this.trackVisit = !"false".equalsIgnoreCase(context.getInitParameter("track-visit")); - this.charset = context.getInitParameter("charset"); } public ConfigXMLReader.ControllerConfig getControllerConfig() { @@ -923,33 +919,21 @@ public class RequestHandler { long viewStartTime = System.currentTimeMillis(); - // setup character encoding and content type - String charset = UtilFormatOut.checkEmpty(this.charset, req.getCharacterEncoding(), "UTF-8"); - + // setup character encoding and content type of the response: + // encoding/charset: use the one set in the view or, if not set, the one set in the request + // content type: use the one set in the view or, if not set, use "text/html" + String charset = req.getCharacterEncoding(); String viewCharset = viewMap.encoding; //NOTE: if the viewCharset is "none" then no charset will be used if (UtilValidate.isNotEmpty(viewCharset)) { charset = viewCharset; } - - if (!"none".equals(charset)) { - try { - req.setCharacterEncoding(charset); - } catch (UnsupportedEncodingException e) { - throw new RequestHandlerException("Could not set character encoding to " + charset, e); - } catch (IllegalStateException e) { - Debug.logInfo(e, "Could not set character encoding to " + charset + ", something has probably already committed the stream", module); - } - } - - // setup content type String contentType = "text/html"; String viewContentType = viewMap.contentType; if (UtilValidate.isNotEmpty(viewContentType)) { contentType = viewContentType; } - - if (charset.length() > 0 && !"none".equals(charset)) { + if (UtilValidate.isNotEmpty(charset) && !"none".equals(charset)) { resp.setContentType(contentType + "; charset=" + charset); } else { resp.setContentType(contentType); diff --git a/specialpurpose/cmssite/src/main/java/org/apache/ofbiz/cmssite/multisite/WebSiteFilter.java b/specialpurpose/cmssite/src/main/java/org/apache/ofbiz/cmssite/multisite/WebSiteFilter.java index 97fd993e0b..670190f00d 100644 --- a/specialpurpose/cmssite/src/main/java/org/apache/ofbiz/cmssite/multisite/WebSiteFilter.java +++ b/specialpurpose/cmssite/src/main/java/org/apache/ofbiz/cmssite/multisite/WebSiteFilter.java @@ -47,7 +47,6 @@ import org.apache.ofbiz.security.Security; import org.apache.ofbiz.security.SecurityConfigurationException; import org.apache.ofbiz.security.SecurityFactory; import org.apache.ofbiz.service.LocalDispatcher; -import org.apache.ofbiz.webapp.WebAppUtil; import org.apache.ofbiz.webapp.control.RequestHandler; import org.apache.ofbiz.webapp.stats.VisitHandler; @@ -77,16 +76,8 @@ public class WebSiteFilter implements Filter { Delegator delegator = (Delegator) httpRequest.getSession().getServletContext().getAttribute("delegator"); LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); - WebAppUtil.setCharacterEncoding(request); - WebAppUtil.setAttributesFromRequestBody(request); - - // set the web context in the request for future use - dispatcher = WebAppUtil.makeWebappDispatcher(session.getServletContext(), delegator); setWebContextObjects(httpRequest, httpResponse, delegator, dispatcher); - request.setAttribute("servletContext", httpRequest.getSession().getServletContext()); - request.setAttribute("delegator", delegator); - GenericValue webSite = null; try { if (UtilValidate.isNotEmpty(webSiteAlias) && UtilValidate.isEmpty(webSite)) { diff --git a/specialpurpose/cmssite/webapp/cmssite/WEB-INF/web.xml b/specialpurpose/cmssite/webapp/cmssite/WEB-INF/web.xml index 499f23b0db..59194ee522 100644 --- a/specialpurpose/cmssite/webapp/cmssite/WEB-INF/web.xml +++ b/specialpurpose/cmssite/webapp/cmssite/WEB-INF/web.xml @@ -49,7 +49,7 @@ under the License. redirectPath - /control/main + /cms diff --git a/specialpurpose/solr/webapp/solr/WEB-INF/controller.xml b/specialpurpose/solr/webapp/solr/WEB-INF/controller.xml index da2cfec188..91a9135353 100644 --- a/specialpurpose/solr/webapp/solr/WEB-INF/controller.xml +++ b/specialpurpose/solr/webapp/solr/WEB-INF/controller.xml @@ -8,9 +8,6 @@ Solr Configuration File - - -