You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Jakob <ja...@jfix.com> on 2002/12/03 15:04:18 UTC

how to serve static content from webserver?

Hi there,

I want static files (images, js, css) be served by the web server (apache
port 80).

I have found a FAQ "How can I improve performance by making the web-server
deliver the static contents?" which partly answers this questions.

I have successfully followed steps 1 and 2.

However, the third list item  "3. Reference the static contents in your
Cocoon app ..." is not clear at all to me.  What am I supposed to do
exactly?

My XSLT stylesheet produces HTML output where, for example all images
paths are created as "/rules/img/[imgname].gif".  Thus, I have created a
<map:match> element as this:

    <map:match pattern="/rules/img/*.gif">
     <map:call resource="resource_images">
      <map:parameter name="target" value="{1}"/>
     </map:call>
    </map:match>

Ok, then I have created this resources snippet which I thought should be
called when the pattern is matched:

  <map:resources>
   <map:resource name="resource_images">
    <map:generate src="/rules/img/{target}.gif"/>
   </map:resource>
  </map:resources>

However, the url of an image is still "localhost:8080/rules/img/[image].gif"

So, I guess this is the wrong approach.  Anybody?

Thanks in advance,
Jakob.


-- 
Jakob.



---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: how to serve static content from webserver?

Posted by Jakob <ja...@jfix.com>.
Alex McLintock said:
> At 14:04 03/12/02, you wrote:
>>I want static files (images, js, css) be served by the web server
>> (apache port 80).
>
> You set up your Apache front end to serve static content - eg from a
> directory called images, or js, or static, and you set up apache to
> forward  dynamic stuff to your java servlet engine and thus Cocoon.
>
> What precisely is the problem you are having?

Actually, in the meantime I have investigated a bit further.

To recall: in my httpd.conf, I added the following line:
    Alias /rules/ "E:/temp/rules/"

In the E:/temp/rules/ directory are all the images, js, css.  Apache
restarted ...

If I have my stylesheet generate a URL like
<script type="text/javascript"
        src="http://localhost:80/rules/go_cocoon.js"></script>

this works.  However, if I instruct it to only generate
<script type="text/javascript" src="/rules/go_cocoon.js"></script>

it won't find the resource.

Well, I am already happy to have it kind of working, but it's not very
portable if I have to construct a full URL for each resource.  There
probably is still a better way than that.

Thanks for your responses so far.

Cheers,
Jakob.



---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: how to serve static content from webserver?

Posted by Geoff Howard <co...@yahoo.com>.
by specifying :8080 you have forced (tomcat) to handle
the image - apache is only listening on 80.  Are you
saying that when you try the same url with default
port 80 you are not seeing the image?  If so,
something is wrong in your first two steps.  Once you
have configured apache to handle the images, you don't
need any of the resource pipeline setup you have
described below.  

How are you serving your dynamic pages?  If they are
on :8080 (no connector to apache, no port forwarding)
then the images are at 80, but you'll have to
construct absolute references to them
(http://localhost/rules/img/[imgname].gif).  Relative
references (/rules...) will reference back to :8080
and bypass.

If, on the other hand you are using some method to
cause your servlet container to be accessed on default
port 80, you need to look into how you are
accomplishing that and whether it is overriding your
attempt to let apache handle static images.

HTH, 
Geoff Howard

--- Jakob <ja...@jfix.com> wrote:
> 
> Hi there,
> 
> I want static files (images, js, css) be served by
> the web server (apache
> port 80).
> 
> I have found a FAQ "How can I improve performance by
> making the web-server
> deliver the static contents?" which partly answers
> this questions.
> 
> I have successfully followed steps 1 and 2.
> 
> However, the third list item  "3. Reference the
> static contents in your
> Cocoon app ..." is not clear at all to me.  What am
> I supposed to do
> exactly?
> 
> My XSLT stylesheet produces HTML output where, for
> example all images
> paths are created as "/rules/img/[imgname].gif". 
> Thus, I have created a
> <map:match> element as this:
> 
>     <map:match pattern="/rules/img/*.gif">
>      <map:call resource="resource_images">
>       <map:parameter name="target" value="{1}"/>
>      </map:call>
>     </map:match>
> 
> Ok, then I have created this resources snippet which
> I thought should be
> called when the pattern is matched:
> 
>   <map:resources>
>    <map:resource name="resource_images">
>     <map:generate src="/rules/img/{target}.gif"/>
>    </map:resource>
>   </map:resources>
> 
> However, the url of an image is still
> "localhost:8080/rules/img/[image].gif"
> 
> So, I guess this is the wrong approach.  Anybody?
> 
> Thanks in advance,
> Jakob.
> 
> 
> -- 
> Jakob.
> 
> 
> 
>
---------------------------------------------------------------------
> Please check that your question  has not already
> been answered in the
> FAQ before posting.    
> <http://xml.apache.org/cocoon/faq/index.html>
> 
> To unsubscribe, e-mail:    
> <co...@xml.apache.org>
> For additional commands, e-mail:  
> <co...@xml.apache.org>
> 


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: how to serve static content from webserver?

Posted by Alex McLintock <al...@OWAL.co.uk>.
At 14:04 03/12/02, you wrote:
>I want static files (images, js, css) be served by the web server (apache
>port 80).

You set up your Apache front end to serve static content - eg from a 
directory called images, or js, or static, and you set up apache to forward 
dynamic stuff to your java servlet engine and thus Cocoon.

What precisely is the problem you are having?

Alex



Openweb Analysts Ltd, London.
Software For Complex Websites http://www.OWAL.co.uk/
Open Source Software Companies please register here 
http://www.OWAL.co.uk/oss_support/


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>