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/10/26 14:09:58 UTC

[C2.0] Source resolution in servlet container

Hi, C2ers!

According to Servlet 2.2 specification (paragraph 4.4):
<quot>
The ServletContext interface allows direct access to the static document
hierarchy of content
documents, such as HTML, GIF, and JPEG files, that are part of the web
application via the
following methods of the ServletContext interface:
. getResource
. getResourceAsStream
</quot>

then:
<quot>
It is important to note that these methods give access to static resources
from whatever repository
the server uses. This hierarchy of documents may exist in a file system, in
a web application archive
file, on a remote server, or some other location.
</quot>

So, from this I can conclude that any other access to static resources is
not required to be supported. As I can see from the CocoonServlet.java
source, it uses calls like this in many places:

final FileInputStream fis = new
FileInputStream(this.servletContext.getRealPath("/") + logkitConfig);

This results in problems with servlet containers (or deployments) that does
not extract files from WAR-archive and therefore the real path is undefined
(is 'null') and CocoonServlet dies during initialization with NPE.

Correct me if I am worng, but to be able to use Cocoon on any servlet engine
that supports Servlet 2.2 specification several rules must be followed in
Cocoon architecture (this must be adapted for CLI):
. any access to static resources of the Web application, including
xsp/xml/xsl files, must be performed by getResource() and
getResourceAsStream methods
. any calls to other servlets must be performed by
RequestDispatcher.include() methods (e.g. JspServlet)
. use working (temporary) directory for any 'write' operations (e.g.
logging)
something else?

Are there any comments on this? Will C2.0 be fixed (at least getRealPath()
issue) before releasing?

Best regards,

Konstantin Piroumian
Sr. Software engineer

Protek Flagship LLC
Phone: + 7 095 795 0520 (add. 1288)
Fax: + 7 095 795 0525
E-mail: kpiroumian@flagship.ru
http://www.protek.com






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


Re: [C2.0] Source resolution in servlet container

Posted by Michael McKibben <mm...@ncube.com>.
Yes, I've been questioning this myself. I don't think it has come up as an
issue yet because in practice most servlet containers do map war resources
to a file path. This problem is not just localized to the CocoonServlet as
the org.apache.cocoon.environment.Context interface has the getRealPath
method as well. I've counted over 30 references in the Cocoon code base to
the getRealPath method. Depending on the context in which it is used, it
may not be possible to convert all uses of getRealPath over to getResource
or getResourceAsStream.

Access to other static resources is supported via standard java.io. Also,
you can access other Servlet Context's (and therefore their static
resources) via ServletContext.getContext(uri). ASAIK, getContext doesn't
have a comparable method in Cocoon's environment Context interface. Of
course, a container's security policy may restrict this access, but that
is up to the administrator what access controls should be given to a war.

Regards,

--mike

On Fri, 26 Oct 2001, Piroumian, Konstantin wrote:

> Hi, C2ers!
>
> According to Servlet 2.2 specification (paragraph 4.4):
> <quot>
> The ServletContext interface allows direct access to the static document
> hierarchy of content
> documents, such as HTML, GIF, and JPEG files, that are part of the web
> application via the
> following methods of the ServletContext interface:
> . getResource
> . getResourceAsStream
> </quot>
>
> then:
> <quot>
> It is important to note that these methods give access to static resources
> from whatever repository
> the server uses. This hierarchy of documents may exist in a file system, in
> a web application archive
> file, on a remote server, or some other location.
> </quot>
>
> So, from this I can conclude that any other access to static resources is
> not required to be supported. As I can see from the CocoonServlet.java
> source, it uses calls like this in many places:
>
> final FileInputStream fis = new
> FileInputStream(this.servletContext.getRealPath("/") + logkitConfig);
>
> This results in problems with servlet containers (or deployments) that does
> not extract files from WAR-archive and therefore the real path is undefined
> (is 'null') and CocoonServlet dies during initialization with NPE.
>
> Correct me if I am worng, but to be able to use Cocoon on any servlet engine
> that supports Servlet 2.2 specification several rules must be followed in
> Cocoon architecture (this must be adapted for CLI):
> . any access to static resources of the Web application, including
> xsp/xml/xsl files, must be performed by getResource() and
> getResourceAsStream methods
> . any calls to other servlets must be performed by
> RequestDispatcher.include() methods (e.g. JspServlet)
> . use working (temporary) directory for any 'write' operations (e.g.
> logging)
> something else?
>
> Are there any comments on this? Will C2.0 be fixed (at least getRealPath()
> issue) before releasing?
>
> Best regards,
>
> Konstantin Piroumian
> Sr. Software engineer
>
> Protek Flagship LLC
> Phone: + 7 095 795 0520 (add. 1288)
> Fax: + 7 095 795 0525
> E-mail: kpiroumian@flagship.ru
> http://www.protek.com
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
> For additional commands, email: cocoon-dev-help@xml.apache.org
>


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


RE: [C2.0] Source resolution in servlet container

Posted by Carsten Ziegeler <cz...@s-und-n.de>.
Hi,

I just started to remove the getRealPath() calls from at least the
CocoonServlet in the 2.1 branch.
But we have one problem with this approach: Cocoon scans on
startup the WEB-INF/lib directory for jar files and builds
the class-path from this. Now I see no possibility to scan
the directory if the war file is not unpacked. Or is there
any chance?

Carsten


> -----Original Message-----
> From: Piroumian, Konstantin [mailto:KPiroumian@flagship.ru]
> Sent: Friday, October 26, 2001 2:10 PM
> To: cocoon-dev@xml.apache.org
> Subject: [C2.0] Source resolution in servlet container
>
>
> Hi, C2ers!
>
> According to Servlet 2.2 specification (paragraph 4.4):
> <quot>
> The ServletContext interface allows direct access to the static document
> hierarchy of content
> documents, such as HTML, GIF, and JPEG files, that are part of the web
> application via the
> following methods of the ServletContext interface:
> . getResource
> . getResourceAsStream
> </quot>
>
> then:
> <quot>
> It is important to note that these methods give access to static resources
> from whatever repository
> the server uses. This hierarchy of documents may exist in a file
> system, in
> a web application archive
> file, on a remote server, or some other location.
> </quot>
>
> So, from this I can conclude that any other access to static resources is
> not required to be supported. As I can see from the CocoonServlet.java
> source, it uses calls like this in many places:
>
> final FileInputStream fis = new
> FileInputStream(this.servletContext.getRealPath("/") + logkitConfig);
>
> This results in problems with servlet containers (or deployments)
> that does
> not extract files from WAR-archive and therefore the real path is
> undefined
> (is 'null') and CocoonServlet dies during initialization with NPE.
>
> Correct me if I am worng, but to be able to use Cocoon on any
> servlet engine
> that supports Servlet 2.2 specification several rules must be followed in
> Cocoon architecture (this must be adapted for CLI):
> . any access to static resources of the Web application, including
> xsp/xml/xsl files, must be performed by getResource() and
> getResourceAsStream methods
> . any calls to other servlets must be performed by
> RequestDispatcher.include() methods (e.g. JspServlet)
> . use working (temporary) directory for any 'write' operations (e.g.
> logging)
> something else?
>
> Are there any comments on this? Will C2.0 be fixed (at least getRealPath()
> issue) before releasing?
>
> Best regards,
>
> Konstantin Piroumian
> Sr. Software engineer
>
> Protek Flagship LLC
> Phone: + 7 095 795 0520 (add. 1288)
> Fax: + 7 095 795 0525
> E-mail: kpiroumian@flagship.ru
> http://www.protek.com
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
> For additional commands, email: cocoon-dev-help@xml.apache.org
>


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