You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by sanu <wr...@gmail.com> on 2012/02/08 08:47:58 UTC

Serving static content using embedded tomcat 7

Hello,

I am working on embedding tomcat 7 into our application. We have a number of
web apps and the static content is located in a different directory, common
to all webapps.

I am not finding a way to serve this static content. Could somebody please
help me out.

Thanks,
Sandhya

--
View this message in context: http://tomcat.10.n6.nabble.com/Serving-static-content-using-embedded-tomcat-7-tp4375155p4375155.html
Sent from the Tomcat - User mailing list archive at Nabble.com.

Re: Serving static content using embedded tomcat 7

Posted by Pid <pi...@pidster.com>.
On 09/02/2012 06:19, sanu wrote:
> Thanks for your reply. I have a global web.xml, where the DefaultServlet is
> mapped.
> 
> The difference I see is that my static resources are not in the same
> directory as the host's appBase. Could this be the problem ? How can the
> static content be served in such a case ?

Folks are quite good at guessing things on this list, but you are making
it harder than it needs to be.  Re-read Mark's answer, follow the link,
read the page carefully.

The rephrase your question and provide some real information.


p


-- 

[key:62590808]


Re: Serving static content using embedded tomcat 7

Posted by sanu <wr...@gmail.com>.
Thanks for your reply. I have a global web.xml, where the DefaultServlet is
mapped.

The difference I see is that my static resources are not in the same
directory as the host's appBase. Could this be the problem ? How can the
static content be served in such a case ?



--
View this message in context: http://tomcat.10.n6.nabble.com/Serving-static-content-using-embedded-tomcat-7-tp4375155p4378249.html
Sent from the Tomcat - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Serving static content using embedded tomcat 7

Posted by Konstantin Kolinko <kn...@gmail.com>.
2012/2/8 sanu <wr...@gmail.com>:
> Thank you.
>
> I just did that. Here's what I have :
>
> StandardContext context = (StandardContext)
>                tomcat.addContext(null, "", <path to the static resource
> directory");
>
> This doesn't seem to work.
>
>(...)


I would guess that you have not created nor mapped the DefaultServlet
instance in your context.

(In standalone Tomcat that mapping is done by conf/web.xml file that
is implicitly combined with every webapp's web.xml file.)

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Serving static content using embedded tomcat 7

Posted by André Warnier <aw...@ice-sa.com>.
Sanu, you are wasting our time, and yours.

sanu wrote:
> Following are the answers to your questions :

not really

> 
> 1) Apache Tomcat/7.0.25

this is ok

> 2) The resources reside in a folder inside the base directory
> 3) The other contexts use relative path to access the static files inside
> this context 
> 

but this is not.  You are not really telling us anything.

> In addition to not being able to access the resources from any other
> context, I am unable to access the static content directly as well. Gives me
> a 404.
> 

Re-read Mark's previous post, and read the document he pointed you to.

Then come back here and provide some *real* information.
Otherwise you are not going to get any more answers.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Serving static content using embedded tomcat 7

Posted by sanu <wr...@gmail.com>.
Following are the answers to your questions :

1) Apache Tomcat/7.0.25
2) The resources reside in a folder inside the base directory
3) The other contexts use relative path to access the static files inside
this context 

In addition to not being able to access the resources from any other
context, I am unable to access the static content directly as well. Gives me
a 404.

Thanks.




--
View this message in context: http://tomcat.10.n6.nabble.com/Serving-static-content-using-embedded-tomcat-7-tp4375155p4375303.html
Sent from the Tomcat - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Serving static content using embedded tomcat 7

Posted by Mark Thomas <ma...@apache.org>.
On 08/02/2012 08:40, sanu wrote:
> Thank you. 
> 
> I just did that. Here's what I have :
> 
> StandardContext context = (StandardContext)
>                 tomcat.addContext(null, "", <path to the static resource
> directory");
> 
> This doesn't seem to work.

You haven't told us:
- exact Apache Tomcat version
- what the path to the resources is
- how the other contexts are referring to these resources

In addition to answering the questions above, I'd strongly recommend
reading [1]. It will help you write better questions which in turn will
get you more useful answers.

Mark

[1] http://catb.org/esr/faqs/smart-questions.html

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Serving static content using embedded tomcat 7

Posted by sanu <wr...@gmail.com>.
Thank you. 

I just did that. Here's what I have :

StandardContext context = (StandardContext)
                tomcat.addContext(null, "", <path to the static resource
directory");

This doesn't seem to work.



--
View this message in context: http://tomcat.10.n6.nabble.com/Serving-static-content-using-embedded-tomcat-7-tp4375155p4375268.html
Sent from the Tomcat - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Serving static content using embedded tomcat 7

Posted by Pid <pi...@pidster.com>.
On 08/02/2012 07:47, sanu wrote:
> Hello,
> 
> I am working on embedding tomcat 7 into our application. We have a number of
> web apps and the static content is located in a different directory, common
> to all webapps.

Why not just serve the static content as it's own application?


> I am not finding a way to serve this static content. 

What have you tried?


> Could somebody please help me out.

If the suggestion above doesn't work, you can try 'aliases', see:

 http://tomcat.apache.org/tomcat-7.0-doc/config/context.html


p

> Thanks,
> Sandhya
> 
> --
> View this message in context: http://tomcat.10.n6.nabble.com/Serving-static-content-using-embedded-tomcat-7-tp4375155p4375155.html
> Sent from the Tomcat - User mailing list archive at Nabble.com.


-- 

[key:62590808]