You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by co...@apache.org on 2001/06/06 08:45:37 UTC
cvs commit: jakarta-tomcat-jasper/jasper34/runtime/org/apache/jasper34/runtime HttpJspBase.java PageContextImpl.java
costin 01/06/05 23:45:37
Modified: jasper34/runtime/org/apache/jasper34/runtime
HttpJspBase.java PageContextImpl.java
Log:
Some changes in runtime to simplify the generated code.
If we extend HttpJspBase ( and our code depends on jasper.runtime.HttpJspBase
anyway ) we can avoid some complexity in the generated code. If we extend
any other class we need of course to generate the old jspService method.
I don't know if using more runtime internals in the generated code is good
or bad, but I know it's almost impossible to generate code that will not
depend on some jasper runtime ( tag pool, HttpJspBase, etc ).
Since we have to use the runtime, it's better to do it in a clean way.
Note that this doesn't affect jasper portability or code independence -
the runtime can/must be included with the generated code ( if jspc is used)
or must be available on the container ( if the container is using jasper )
Revision Changes Path
1.2 +53 -4 jakarta-tomcat-jasper/jasper34/runtime/org/apache/jasper34/runtime/HttpJspBase.java
Index: HttpJspBase.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-jasper/jasper34/runtime/org/apache/jasper34/runtime/HttpJspBase.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- HttpJspBase.java 2001/05/27 23:09:20 1.1
+++ HttpJspBase.java 2001/06/06 06:45:33 1.2
@@ -81,6 +81,7 @@
private ClassLoader cl;
protected PageContext pageContext;
+ protected JspFactory _jspxFactory = null;
protected HttpJspBase() {
}
@@ -89,6 +90,7 @@
throws ServletException
{
super.init(config);
+ _jspxFactory = JspFactory.getDefaultFactory();
jspInit();
}
@@ -113,10 +115,43 @@
/**
* Entry point into service.
*/
- public final void service(HttpServletRequest request, HttpServletResponse response)
+ public final void service(HttpServletRequest request,
+ HttpServletResponse response)
throws ServletException, IOException
{
- _jspService(request, response);
+
+ PageContext pageContext=null;
+ try {
+ try {
+ _jspx_init(); // need to be in init !
+ pageContext = _getPageContext( request, response );
+ _jspService(pageContext, request, response );
+ } catch (Exception ex) {
+ if (pageContext != null)
+ pageContext.handlePageException(ex);
+ } catch (Error error) {
+ throw error;
+ } catch (Throwable throwable) {
+ throw new ServletException(throwable);
+ }
+ } finally {
+ IOException err=null;
+ if( pageContext!=null ) {
+ try {
+ JspWriterImpl out=(JspWriterImpl)pageContext.getOut();
+ if( out != null )
+ out.flushBuffer();
+ } catch( IOException ex ) {
+ err=ex;
+ // handlePageException( ex );
+ // This was a bug in previous implementations:
+ // if flushBuffer throws exceptions release() is not
+ // corectly called !( this was part of the generated code )
+ }
+ }
+ _jspxFactory.releasePageContext(pageContext);
+ if( err!=null ) throw err;
+ }
}
public void jspInit() {
@@ -124,8 +159,22 @@
public void jspDestroy() {
}
+
+ public abstract void _jspx_init()
+ throws Throwable;
+
+ public abstract PageContext _getPageContext(HttpServletRequest request,
+ HttpServletResponse response);
+
- public abstract void _jspService(HttpServletRequest request,
+ public abstract void _jspService(PageContext pageContext,
+ HttpServletRequest request,
HttpServletResponse response)
- throws ServletException, IOException;
+ throws Throwable;
+
+ public void _jspService(HttpServletRequest request,
+ HttpServletResponse response)
+ throws ServletException, IOException {
+ }
+
}
1.2 +5 -2 jakarta-tomcat-jasper/jasper34/runtime/org/apache/jasper34/runtime/PageContextImpl.java
Index: PageContextImpl.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-jasper/jasper34/runtime/org/apache/jasper34/runtime/PageContextImpl.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PageContextImpl.java 2001/05/27 23:09:20 1.1
+++ PageContextImpl.java 2001/06/06 06:45:34 1.2
@@ -433,8 +433,11 @@
}
public void handlePageException(Exception e)
- throws IOException, ServletException {
-
+ throws IOException, ServletException
+ {
+ if( out!= null && out.getBufferSize() != 0) {
+ out.clearBuffer();
+ }
// set the request attribute with the exception.
request.setAttribute("javax.servlet.jsp.jspException", e);