vgritsenko 2003/06/07 16:01:48
Modified: src/blocks/jsp/java/org/apache/cocoon/components/jsp JSPEngine.java JSPEngineImpl.java src/blocks/jsp/java/org/apache/cocoon/generation JspGenerator.java src/blocks/jsp/java/org/apache/cocoon/reading JSPReader.java Log: clearify JSPEngine contract; fix some javadoc; add fixmes Revision Changes Path 1.2 +10 -9 cocoon-2.1/src/blocks/jsp/java/org/apache/cocoon/components/jsp/JSPEngine.java Index: JSPEngine.java =================================================================== RCS file: /home/cvs/cocoon-2.1/src/blocks/jsp/java/org/apache/cocoon/components/jsp/JSPEngine.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- JSPEngine.java 9 Mar 2003 00:04:12 -0000 1.1 +++ JSPEngine.java 7 Jun 2003 23:01:48 -0000 1.2 @@ -70,14 +70,15 @@ String ROLE = JSPEngine.class.getName(); /** - * execute the JSP and return the output - * - * @param context The Servlet Context - * @exception IOException - * @exception ServletException - * @exception SAXException - * @exception Exception - */ + * Execute the JSP and return the output. + * Output of the JSPEngine <b>must</b> be in UTF8 encoding. + * + * @param context The Servlet Context + * @exception IOException + * @exception ServletException + * @exception SAXException + * @exception Exception + */ byte[] executeJSP(String url, HttpServletRequest request, HttpServletResponse response, 1.5 +4 -5 cocoon-2.1/src/blocks/jsp/java/org/apache/cocoon/components/jsp/JSPEngineImpl.java Index: JSPEngineImpl.java =================================================================== RCS file: /home/cvs/cocoon-2.1/src/blocks/jsp/java/org/apache/cocoon/components/jsp/JSPEngineImpl.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- JSPEngineImpl.java 30 May 2003 15:31:58 -0000 1.4 +++ JSPEngineImpl.java 7 Jun 2003 23:01:48 -0000 1.5 @@ -93,20 +93,18 @@ /** * Set the sitemap-provided configuration. - * @param conf The configuration information - * @exception ConfigurationException + * @param params The configuration parameters */ public void parameterize(Parameters params) { this.jspServletClass = params.getParameter("servlet-class", DEFAULT_SERVLET_CLASS); } /** - * execute the JSP and return the output + * execute the JSP and return the output in UTF8 encoding * * @param context The Servlet Context * @exception IOException * @exception ServletException - * @exception SAXException * @exception Exception */ public byte[] executeJSP(String url, HttpServletRequest httpRequest, HttpServletResponse httpResponse, ServletContext context) @@ -261,6 +259,7 @@ public void setLocale(java.util.Locale loc) {} public ServletOutputStream getOutputStream() { if (this.output == null) { + // FIXME: Won't it break JSPEngine contract? See JSPEngine.executeJSP this.output = new MyServletOutputStream(this.encoding); } return this.output; 1.2 +2 -4 cocoon-2.1/src/blocks/jsp/java/org/apache/cocoon/generation/JspGenerator.java Index: JspGenerator.java =================================================================== RCS file: /home/cvs/cocoon-2.1/src/blocks/jsp/java/org/apache/cocoon/generation/JspGenerator.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- JspGenerator.java 9 Mar 2003 00:04:14 -0000 1.1 +++ JspGenerator.java 7 Jun 2003 23:01:48 -0000 1.2 @@ -116,12 +116,10 @@ engine = (JSPEngine)this.manager.lookup(JSPEngine.ROLE); getLogger().debug("JspGenerator executing JSP:" + url); - byte[] bytes = engine.executeJSP(url, httpRequest, httpResponse, httpContext); - // explicitly specify bytestream encoding InputSource input = new InputSource(new ByteArrayInputStream(bytes)); - // FIXME (KP): Why do we need this? + // utf-8 is default encoding; specified explicitely here as a reminder. input.setEncoding("utf-8"); // pipe the results into the parser 1.2 +2 -3 cocoon-2.1/src/blocks/jsp/java/org/apache/cocoon/reading/JSPReader.java Index: JSPReader.java =================================================================== RCS file: /home/cvs/cocoon-2.1/src/blocks/jsp/java/org/apache/cocoon/reading/JSPReader.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- JSPReader.java 9 Mar 2003 00:04:15 -0000 1.1 +++ JSPReader.java 7 Jun 2003 23:01:48 -0000 1.2 @@ -93,7 +93,6 @@ JSPEngine engine = null; try { - // FIXME (KP): Should we exclude not supported protocols, say 'context'? String url = this.source; @@ -117,6 +116,7 @@ byte[] buffer = new byte[8192]; int length = -1; + // TODO: Recode from UTF8 to desired output encoding. ByteArrayInputStream bais = new ByteArrayInputStream(bytes); while ((length = bais.read(buffer)) > -1) { out.write(buffer, 0, length); @@ -124,7 +124,6 @@ bais.close(); bais = null; out.flush(); - // } catch (ServletException e) { throw new ProcessingException("ServletException in JSPReader.generate()",e.getRootCause()); } catch (IOException e) {