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/30 16:10:41 UTC

[C2] Source path relative to servlet context

Hi, all!

Can anybody help me with path resolution? I need a path relative to the
servlet context, which I will pass to JspEngine/JspServlet for processing.
In my sitemap I have:

<map:match pattern="test/welcome.htm">
     <map:read src="path-to-jsp/welcome.jsp" type="jsp"
mime-type="text/html"/>
</map:match>

When I use an absolute path path-to-jsp = "/jsp/welcome.jsp" then this
resolves to "file:/jsp/welcome.jsp" and I strip the "file:" and pass
"/jsp/welcome.jsp" to JSPEngine and this works.

When I use path-to-jsp = "context://jsp/welcome.jsp" the path resolves to an
absolute path, say: "file:/C:/tomcat/webapps/cocoon2/jsp/welcome.jsp" and
JspServlet calls getRealPath() with this and gets the path prefixed with
servlet context path twice. And of course it gives File Not Found error.

The same thing happens with relative path path-to-jsp-dir =
"jsp/welcome.jsp". I get an exception because of a wrong file path and File
Not Found error is returned.

So, to conclude all this: I need a path relative to the servlet contex.
/jsp/welcome.jsp ==> /jsp/welcome.jsp
jsp/welcome.jsp ==> <request-path>/jsp/welcome.jsp
context://jsp/welcome.jsp ==> /jsp/welcome.jsp
etc.

Are there any hints where do I start? Somewhere in URLFactoryImpl?

Any help is very appreciated.

Regards,
    Konstantin Piroumian




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


Re: [C2] Source path relative to servlet context

Posted by "Piroumian, Konstantin" <KP...@flagship.ru>.
Yes, I will post them with the JSPReader.
Do you think, that path resolution part must be done inside of
JSPEngineXXXs? Just now I do it in my JSPReader generate() method.

Btw, is that correct that
resolver.resolve(source).getSystemId();
returns a system dependent path (with '\' separators for Windows), but
contextDir path uses '/'s?

> Konstantin,
>
> Will you have some time to post patches to the JSPEngineXXXX files?
>
> Thanks,
> dims
>
> --- "Piroumian, Konstantin" <KP...@flagship.ru> wrote:
> > Thank you very much!
> >
> > This was the way that I would use if nobody would show me a better way
or
> > more unified. ;)
> > Maybe this must be added to the Source interface? Somthing like:
> > Source.getContextId() ?
> >
> > > Konstantin,
> > >
> > > Check ProgramGeneratorImpl.java, lines 150-164.
> > > Hope this helps.
> > >
> > > Vadim
> > >
> > > > -----Original Message-----
> > > > From: Piroumian, Konstantin [mailto:KPiroumian@flagship.ru]
> > > > Sent: Thursday, August 30, 2001 10:11 AM
> > > > To: cocoon-dev@xml.apache.org
> > > > Subject: [C2] Source path relative to servlet context
> > > >
> > > >
> > > > Hi, all!
> > > >
> > > > Can anybody help me with path resolution? I need a path relative to
the
> > > > servlet context, which I will pass to JspEngine/JspServlet for
> > processing.
> > > > In my sitemap I have:
> > > >
> > > > <map:match pattern="test/welcome.htm">
> > > >      <map:read src="path-to-jsp/welcome.jsp" type="jsp"
> > > > mime-type="text/html"/>
> > > > </map:match>
> > > >
> > > > When I use an absolute path path-to-jsp = "/jsp/welcome.jsp" then
this
> > > > resolves to "file:/jsp/welcome.jsp" and I strip the "file:" and pass
> > > > "/jsp/welcome.jsp" to JSPEngine and this works.
> > > >
> > > > When I use path-to-jsp = "context://jsp/welcome.jsp" the path
resolves
> > to an
> > > > absolute path, say:
"file:/C:/tomcat/webapps/cocoon2/jsp/welcome.jsp"
> > and
> > > > JspServlet calls getRealPath() with this and gets the path prefixed
with
> > > > servlet context path twice. And of course it gives File Not Found
error.
> > > >
> > > > The same thing happens with relative path path-to-jsp-dir =
> > > > "jsp/welcome.jsp". I get an exception because of a wrong file path
and
> > File
> > > > Not Found error is returned.
> > > >
> > > > So, to conclude all this: I need a path relative to the servlet
contex.
> > > > /jsp/welcome.jsp ==> /jsp/welcome.jsp
> > > > jsp/welcome.jsp ==> <request-path>/jsp/welcome.jsp
> > > > context://jsp/welcome.jsp ==> /jsp/welcome.jsp
> > > > etc.
> > > >
> > > > Are there any hints where do I start? Somewhere in URLFactoryImpl?
> > > >
> > > > Any help is very appreciated.
> > > >
> > > > Regards,
> > > >     Konstantin Piroumian
> > > >
> > > >
> > > >
> > > >
> > >
> ---------------------------------------------------------------------
> > > > 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
> > >
> >
> > ---------------------------------------------------------------------
> > 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
>

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


Re: [C2] Source path relative to servlet context

Posted by Davanum Srinivas <di...@yahoo.com>.
Konstantin,

Will you have some time to post patches to the JSPEngineXXXX files?

Thanks,
dims

--- "Piroumian, Konstantin" <KP...@flagship.ru> wrote:
> Thank you very much!
> 
> This was the way that I would use if nobody would show me a better way or
> more unified. ;)
> Maybe this must be added to the Source interface? Somthing like:
> Source.getContextId() ?
> 
> > Konstantin,
> >
> > Check ProgramGeneratorImpl.java, lines 150-164.
> > Hope this helps.
> >
> > Vadim
> >
> > > -----Original Message-----
> > > From: Piroumian, Konstantin [mailto:KPiroumian@flagship.ru]
> > > Sent: Thursday, August 30, 2001 10:11 AM
> > > To: cocoon-dev@xml.apache.org
> > > Subject: [C2] Source path relative to servlet context
> > >
> > >
> > > Hi, all!
> > >
> > > Can anybody help me with path resolution? I need a path relative to the
> > > servlet context, which I will pass to JspEngine/JspServlet for
> processing.
> > > In my sitemap I have:
> > >
> > > <map:match pattern="test/welcome.htm">
> > >      <map:read src="path-to-jsp/welcome.jsp" type="jsp"
> > > mime-type="text/html"/>
> > > </map:match>
> > >
> > > When I use an absolute path path-to-jsp = "/jsp/welcome.jsp" then this
> > > resolves to "file:/jsp/welcome.jsp" and I strip the "file:" and pass
> > > "/jsp/welcome.jsp" to JSPEngine and this works.
> > >
> > > When I use path-to-jsp = "context://jsp/welcome.jsp" the path resolves
> to an
> > > absolute path, say: "file:/C:/tomcat/webapps/cocoon2/jsp/welcome.jsp"
> and
> > > JspServlet calls getRealPath() with this and gets the path prefixed with
> > > servlet context path twice. And of course it gives File Not Found error.
> > >
> > > The same thing happens with relative path path-to-jsp-dir =
> > > "jsp/welcome.jsp". I get an exception because of a wrong file path and
> File
> > > Not Found error is returned.
> > >
> > > So, to conclude all this: I need a path relative to the servlet contex.
> > > /jsp/welcome.jsp ==> /jsp/welcome.jsp
> > > jsp/welcome.jsp ==> <request-path>/jsp/welcome.jsp
> > > context://jsp/welcome.jsp ==> /jsp/welcome.jsp
> > > etc.
> > >
> > > Are there any hints where do I start? Somewhere in URLFactoryImpl?
> > >
> > > Any help is very appreciated.
> > >
> > > Regards,
> > >     Konstantin Piroumian
> > >
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > 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
> >
> 
> ---------------------------------------------------------------------
> 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


Re: [C2] Source path relative to servlet context

Posted by "Piroumian, Konstantin" <KP...@flagship.ru>.
Thank you very much!

This was the way that I would use if nobody would show me a better way or
more unified. ;)
Maybe this must be added to the Source interface? Somthing like:
Source.getContextId() ?

> Konstantin,
>
> Check ProgramGeneratorImpl.java, lines 150-164.
> Hope this helps.
>
> Vadim
>
> > -----Original Message-----
> > From: Piroumian, Konstantin [mailto:KPiroumian@flagship.ru]
> > Sent: Thursday, August 30, 2001 10:11 AM
> > To: cocoon-dev@xml.apache.org
> > Subject: [C2] Source path relative to servlet context
> >
> >
> > Hi, all!
> >
> > Can anybody help me with path resolution? I need a path relative to the
> > servlet context, which I will pass to JspEngine/JspServlet for
processing.
> > In my sitemap I have:
> >
> > <map:match pattern="test/welcome.htm">
> >      <map:read src="path-to-jsp/welcome.jsp" type="jsp"
> > mime-type="text/html"/>
> > </map:match>
> >
> > When I use an absolute path path-to-jsp = "/jsp/welcome.jsp" then this
> > resolves to "file:/jsp/welcome.jsp" and I strip the "file:" and pass
> > "/jsp/welcome.jsp" to JSPEngine and this works.
> >
> > When I use path-to-jsp = "context://jsp/welcome.jsp" the path resolves
to an
> > absolute path, say: "file:/C:/tomcat/webapps/cocoon2/jsp/welcome.jsp"
and
> > JspServlet calls getRealPath() with this and gets the path prefixed with
> > servlet context path twice. And of course it gives File Not Found error.
> >
> > The same thing happens with relative path path-to-jsp-dir =
> > "jsp/welcome.jsp". I get an exception because of a wrong file path and
File
> > Not Found error is returned.
> >
> > So, to conclude all this: I need a path relative to the servlet contex.
> > /jsp/welcome.jsp ==> /jsp/welcome.jsp
> > jsp/welcome.jsp ==> <request-path>/jsp/welcome.jsp
> > context://jsp/welcome.jsp ==> /jsp/welcome.jsp
> > etc.
> >
> > Are there any hints where do I start? Somewhere in URLFactoryImpl?
> >
> > Any help is very appreciated.
> >
> > Regards,
> >     Konstantin Piroumian
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > 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
>

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


RE: [C2] Source path relative to servlet context

Posted by Vadim Gritsenko <vg...@hns.com>.
Konstantin,

Check ProgramGeneratorImpl.java, lines 150-164.
Hope this helps.

Vadim

> -----Original Message-----
> From: Piroumian, Konstantin [mailto:KPiroumian@flagship.ru]
> Sent: Thursday, August 30, 2001 10:11 AM
> To: cocoon-dev@xml.apache.org
> Subject: [C2] Source path relative to servlet context
> 
> 
> Hi, all!
> 
> Can anybody help me with path resolution? I need a path relative to the
> servlet context, which I will pass to JspEngine/JspServlet for processing.
> In my sitemap I have:
> 
> <map:match pattern="test/welcome.htm">
>      <map:read src="path-to-jsp/welcome.jsp" type="jsp"
> mime-type="text/html"/>
> </map:match>
> 
> When I use an absolute path path-to-jsp = "/jsp/welcome.jsp" then this
> resolves to "file:/jsp/welcome.jsp" and I strip the "file:" and pass
> "/jsp/welcome.jsp" to JSPEngine and this works.
> 
> When I use path-to-jsp = "context://jsp/welcome.jsp" the path resolves to an
> absolute path, say: "file:/C:/tomcat/webapps/cocoon2/jsp/welcome.jsp" and
> JspServlet calls getRealPath() with this and gets the path prefixed with
> servlet context path twice. And of course it gives File Not Found error.
> 
> The same thing happens with relative path path-to-jsp-dir =
> "jsp/welcome.jsp". I get an exception because of a wrong file path and File
> Not Found error is returned.
> 
> So, to conclude all this: I need a path relative to the servlet contex.
> /jsp/welcome.jsp ==> /jsp/welcome.jsp
> jsp/welcome.jsp ==> <request-path>/jsp/welcome.jsp
> context://jsp/welcome.jsp ==> /jsp/welcome.jsp
> etc.
> 
> Are there any hints where do I start? Somewhere in URLFactoryImpl?
> 
> Any help is very appreciated.
> 
> Regards,
>     Konstantin Piroumian
> 
> 
> 
> 
> ---------------------------------------------------------------------
> 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] Source path relative to servlet context

Posted by "Piroumian, Konstantin" <KP...@flagship.ru>.
> On Thu, 30 Aug 2001, Piroumian, Konstantin wrote:
>
> Konstantin, I really don't know why you need that. It has worked for
> months now and why should we change URLFactoryImpl and what do we gain?

I didn't ask you to change anything, I only needed an advice about that. I
need a relative to context path, because I have to pass that path to a JSP
servlet (any, not only Apache Jasper), otherwise it won't work.

> I think either JspServlet is wrong or your implementation of the
> jsp-reader, don't you think? I would like you to try to use the
> HttpContext in your jsp-reader to determine the context relative portion
> of the src value.

I am using that method  now (thanks to Vadim Gritsenko who gave me the
hint). The JspServlet is not wrong - it works as expected by the
specification (Servlet ans JSP). The implementation of JSPReader is in work,
so it is possible to be wrong ;)

Btw, I tried to make my JSPReader Contextualiazable, but it seems that
contextualize method was never called. What's can wrong: a reader cannot be
contextualizable or I do something wrong?

Thanks for any help.

>
> Giacomo
>
> > Hi, all!
> >
> > Can anybody help me with path resolution? I need a path relative to the
> > servlet context, which I will pass to JspEngine/JspServlet for
processing.
> > In my sitemap I have:
> >
> > <map:match pattern="test/welcome.htm">
> >      <map:read src="path-to-jsp/welcome.jsp" type="jsp"
> > mime-type="text/html"/>
> > </map:match>
> >
> > When I use an absolute path path-to-jsp = "/jsp/welcome.jsp" then this
> > resolves to "file:/jsp/welcome.jsp" and I strip the "file:" and pass
> > "/jsp/welcome.jsp" to JSPEngine and this works.
> >
> > When I use path-to-jsp = "context://jsp/welcome.jsp" the path resolves
to an
> > absolute path, say: "file:/C:/tomcat/webapps/cocoon2/jsp/welcome.jsp"
and
> > JspServlet calls getRealPath() with this and gets the path prefixed with
> > servlet context path twice. And of course it gives File Not Found error.
> >
> > The same thing happens with relative path path-to-jsp-dir =
> > "jsp/welcome.jsp". I get an exception because of a wrong file path and
File
> > Not Found error is returned.
> >
> > So, to conclude all this: I need a path relative to the servlet contex.
> > /jsp/welcome.jsp ==> /jsp/welcome.jsp
> > jsp/welcome.jsp ==> <request-path>/jsp/welcome.jsp
> > context://jsp/welcome.jsp ==> /jsp/welcome.jsp
> > etc.
> >
> > Are there any hints where do I start? Somewhere in URLFactoryImpl?
> >
> > Any help is very appreciated.
> >
> > Regards,
> >     Konstantin Piroumian


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


Re: [C2] Source path relative to servlet context

Posted by giacomo <gi...@apache.org>.
On Thu, 30 Aug 2001, Piroumian, Konstantin wrote:

Konstantin, I really don't know why you need that. It has worked for
months now and why should we change URLFactoryImpl and what do we gain?
I think either JspServlet is wrong or your implementation of the
jsp-reader, don't you think? I would like you to try to use the
HttpContext in your jsp-reader to determine the context relative portion
of the src value.

Giacomo

> Hi, all!
>
> Can anybody help me with path resolution? I need a path relative to the
> servlet context, which I will pass to JspEngine/JspServlet for processing.
> In my sitemap I have:
>
> <map:match pattern="test/welcome.htm">
>      <map:read src="path-to-jsp/welcome.jsp" type="jsp"
> mime-type="text/html"/>
> </map:match>
>
> When I use an absolute path path-to-jsp = "/jsp/welcome.jsp" then this
> resolves to "file:/jsp/welcome.jsp" and I strip the "file:" and pass
> "/jsp/welcome.jsp" to JSPEngine and this works.
>
> When I use path-to-jsp = "context://jsp/welcome.jsp" the path resolves to an
> absolute path, say: "file:/C:/tomcat/webapps/cocoon2/jsp/welcome.jsp" and
> JspServlet calls getRealPath() with this and gets the path prefixed with
> servlet context path twice. And of course it gives File Not Found error.
>
> The same thing happens with relative path path-to-jsp-dir =
> "jsp/welcome.jsp". I get an exception because of a wrong file path and File
> Not Found error is returned.
>
> So, to conclude all this: I need a path relative to the servlet contex.
> /jsp/welcome.jsp ==> /jsp/welcome.jsp
> jsp/welcome.jsp ==> <request-path>/jsp/welcome.jsp
> context://jsp/welcome.jsp ==> /jsp/welcome.jsp
> etc.
>
> Are there any hints where do I start? Somewhere in URLFactoryImpl?
>
> Any help is very appreciated.
>
> Regards,
>     Konstantin Piroumian
>
>
>
>
> ---------------------------------------------------------------------
> 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