You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by "Piroumian, Konstantin" <KP...@flagship.ru> on 2001/08/29 17:36:38 UTC

JSPEngineImpl

Hi, dims and team!

I am working on a JSPReader, which will allow to output a JSP page generated
content from the sitemap (not XML!). This will allow to use C2 as a
controller servlet (controlled by the sitemap), but use JSP in its usual
way: outputting HTML.

And I have a few questions about the JSPEngine implementations:

The first question is about the MyServletRequest and MyServletResponse
classes. Is there a reason that they don't extend HttpServletRequest and
...Response classes but implement interfaces completely? Wouldn't it be
better and easier just to extend those classes and override needed methods?

As I can see, JSPEngine returns byte array. Wouldn't it be better to have a
possibility to specify an output stream for JSP servlet? Just a though, I
have to look at it more carefully.

Another problem with the source path. JSP engine uses the real file path to
open the source, but when I specify something like context://jsp/welcome.jsp
then I get a Protocol not supported error. If I remove the check for
"file:/" prefix I get another error: File not found (the app context path is
appended twice). If I use a relative path 'jsp/welcome.jsp' then the path
resolves correctly but JspServlet returns File not found error.

I've attached the source, if anybody is interested. To make it work with
Tomcat 3.3 I had to copy jasper.jar and servlet.jar to
context://WEB-INF/lib. And added this lines to sitemap:

<map:match pattern="test/*.htm">
     <map:read src="/jsp/{1}.jsp" type="jsp" mime-type="text/html"/>
</map:match>

Currently, this is the only way to get it running correctly.

Are there any suggestion/comments how to change/improve JSPEngine to be used
not only for a generator, but in any case, when an output from JSP page is
needed, particularly, in JSPReader.

Regards,
    Konstantin Piroumian.






Re: JSPEngineImpl

Posted by Davanum Srinivas <di...@yahoo.com>.
Konstantin,
The JSP support evolved over time, so am not sure that i remember all the answers....Anyway please
see below.

Thanks,
dims

--- "Piroumian, Konstantin" <KP...@flagship.ru> wrote:
> Hi, dims and team!
> 
> I am working on a JSPReader, which will allow to output a JSP page generated
> content from the sitemap (not XML!). This will allow to use C2 as a
> controller servlet (controlled by the sitemap), but use JSP in its usual
> way: outputting HTML.
> 
> And I have a few questions about the JSPEngine implementations:
> 
> The first question is about the MyServletRequest and MyServletResponse
> classes. Is there a reason that they don't extend HttpServletRequest and
> ...Response classes but implement interfaces completely? Wouldn't it be
> better and easier just to extend those classes and override needed methods?

The default HttpServletRequest/Response classes do some quirky things (see tomcat sources for
example). We need to control every aspect and make sure that the environment we are working in is
not clobbered by the things that happen when we extend MyServletXXXX classes from HttpServletXXXX.

> As I can see, JSPEngine returns byte array. Wouldn't it be better to have a
> possibility to specify an output stream for JSP servlet? Just a though, I
> have to look at it more carefully.

Could have been done either way....

> Another problem with the source path. JSP engine uses the real file path to
> open the source, but when I specify something like context://jsp/welcome.jsp
> then I get a Protocol not supported error. If I remove the check for
> "file:/" prefix I get another error: File not found (the app context path is
> appended twice). If I use a relative path 'jsp/welcome.jsp' then the path
> resolves correctly but JspServlet returns File not found error.

Any patches here are welcome.

> I've attached the source, if anybody is interested. To make it work with
> Tomcat 3.3 I had to copy jasper.jar and servlet.jar to
> context://WEB-INF/lib. 

Yes. The build script's don't do this by default as the jsp support is implemented in myriad ways
depending on the servlet container.

> And added this lines to sitemap:
> 
> <map:match pattern="test/*.htm">
>      <map:read src="/jsp/{1}.jsp" type="jsp" mime-type="text/html"/>
> </map:match>
> 
> Currently, this is the only way to get it running correctly.
> 
> Are there any suggestion/comments how to change/improve JSPEngine to be used
> not only for a generator, but in any case, when an output from JSP page is
> needed, particularly, in JSPReader.
> 
> Regards,
>     Konstantin Piroumian.
> 
> 
> 
> 
> 
> 

> ATTACHMENT part 2 application/x-javascript name=JSPReader.java
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
> For additional commands, email: cocoon-dev-help@xml.apache.org


=====
Davanum Srinivas, JNI-FAQ Manager
http://www.jGuru.com/faq/JNI

__________________________________________________
Do You Yahoo!?
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger
http://im.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org