RE: [jetty-user] How to link to images from servlet

andrej rolih <[email protected]>
Newsgroups gmane.comp.java.jetty.support
Message-ID <[email protected]>
Thank you. After a lot of digging in those examples I finally found these three lines of code that did what I wanted to:

ServletHolder holder = context.addServlet(org.eclipse.jetty.servlet.DefaultServlet.class,"/tmp/*");
holder.setInitParameter("resourceBase","/tmp");
holder.setInitParameter("pathInfoOnly","true"); 

Now I can get to the servlet if I simply enter the localhost:8080/ and to the files if I enter localhost:8080/tmp.


> Date: Thu, 24 Feb 2011 18:36:57 -0600
> From: [email protected]
> To: [email protected]
> Subject: Re: [jetty-user] How to link to images from servlet
> 
> look at the embedded examples as previously mentioned, they will guide
> your course
> 
> http://dev.eclipse.org/viewsvn/viewvc.cgi/jetty/trunk/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/?root=RT_JETTY
> 
> cheers,
> jesse
> 
> --
> jesse mcconnell
> [email protected]
> 
> 
> 
> On Thu, Feb 24, 2011 at 14:05, andrej rolih <[email protected]> wrote:
> >
> > I managed to add the DefaultServlet so when I go to localhost:8080/files I
> > get a 404. Any other URL and I get to my servlet. Problem is that I don't
> > know how to configure the DefaultServlet to serve my images/css files.
> > ________________________________
> > From: [email protected]
> > Date: Thu, 24 Feb 2011 14:00:40 -0500
> > To: [email protected]
> > CC: [email protected]
> > Subject: Re: [jetty-user] How to link to images from servlet
> >
> > You should add org.eclipse.jetty.servlet.DefaultServlet to your
> > ServletContextHandler and map it to some context path (e.g. /images/*), and
> > configure the DefaultSerlvet to serve the images from the location of your
> > choice. Please see Embedding Jetty tutorial for more information.
> >
> > On Thu, Feb 24, 2011 at 7:01 AM, andrej rolih <[email protected]> wrote:
> >
> > Can you explain this a little? What sort of filter? How can I implement it?
> > All I want is to display images in the servlet. Problem is that I don't know
> > how to get to them. Oh and the server itself is embedded into my application
> > - if this changes anything.
> >
> > ________________________________
> > Date: Wed, 23 Feb 2011 18:12:33 -0800
> > From: [email protected]
> > To: [email protected]
> > CC: [email protected]
> > Subject: Re: [jetty-user] How to link to images from servlet
> >
> > On 2/23/2011 5:20 PM, andrej rolih wrote:
> >
> > Hi!
> > I have a one ServletContextHandler with one servlet added - with path "/*".
> > Problem is that I don't know how to serve a simple image/stylesheet. If I
> > open localhost:8080/ my servlet appears, if I open localhost:8080/whatever
> > my servlet appears ... I want / to be reserved for the servlet but I need
> > something like /files to serve my images/stylesheets. Problem is that I
> > don't know how to serve static contect inside my servlet.
> >
> > Thank you for any help!
> >
> > It sounds like a filter would better suit your needs.
> >
> > --
> > Lobos Studios - Website Design, Programming, IT Support
> > Phone: 877.919.4WEB (877.919.4932) (Toll-free)
> > Phone: 760.684.8859 (Victor Valley)
> > www.LobosStudios.com -- www.facebook.com/LobosStudios
> >
> >
> > www.twitter.com/LobosStudios
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
> 
>     http://xircles.codehaus.org/manage_email
> 
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.