How can I intercept the output of the JSP engine (before it is delivered to the client), so that I can manipulate it before sending it to the connecting client?

Serge Knystautas

As a design principle in JSP 1.1/Servlet 2.2, there is not a way to do this.

There is a way to do a version of this manipulation, however, using a custom tag library. You can wrap a custom tag around your entire JSP, and then your custom tag can view what was generated by the JSP code and perform any manipulations it wants before sending something on to the browser. Your JSP page might look something like this:

<%@ taglib uri="mytaglib.tld" prefix="custom" %>
<custom:manipulate>

My existing JSP.
<%
int i = 0;
%>
<%=i%>
Done.

</custom:manipulate>

In the JSP 1.2/Servlet 2.3 spec (which will not be published in final form until near the end of 2000), there is a new concept of a servlet filter. A servlet filter is a new class that can manipulate the output of a servlet or JSP, exactly as you request. Read the Servlet 2.3 specification to see how this works.

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact