I don't see why you can't just modify the example I made to expose the files at 
the right place. Separating the servlet and the static files in different 
bundles might not be a bad idea...

However, you might want to take a look at 
org.eclipse.jetty.servlet.DefaultServlet ( 
http://download.eclipse.org/jetty/stable-7/apidocs/index.html?org/eclipse/jetty/servlet/DefaultServlet.html
 ). I've never used it myself, so I'll leave it to someone else to chime in on 
whether that's a good idea or not, but chances are you can make it do what you 
want.

// Henrik

On Feb 17, 2011, at 18:50 , Mitul Adhia wrote:

> HI Henrik,
> 
> Actually previously i was using jetty 6.1 in which i was using HttpService to 
> register the servlet & resource dynamically ..
> Below is the code snippet which i was using it ...
> 
> ServiceReference reference = 
> context.getServiceReference(HttpService.class.getName());
>               
>               if(reference!=null){
>                       HttpService service = (HttpService) 
> context.getService(reference);
>                       HttpContext httpContext = 
> service.createDefaultHttpContext();                   
>                       service.registerServlet("/lmauto", dispatcher, new 
> Properties(), httpContext);
>                       service.registerResources("/flex", "/lmautoFlex", 
> httpContext);
>                       
> }
> 
> Now for flex ui i was using following url 
> http://localhost:8080/flexui/index.html .. were flexui is context path and 
> static html is index.html ..
> So now i wanted to use jetty 7.2.2 without change of url ..i tried the 
> example from url http://wiki.eclipse.org/Jetty/Tutorial/Embedding_Jetty 
> but did not succeeded .
> 
> Can you provide me how to use ResourceHandler class which can help me to 
> access the static file without change in the url .
> 
> Best Regards,
> mitul
> 
> 
> 
> On Thu, Feb 17, 2011 at 10:14 PM, Henrik Gustafsson 
> <[email protected]> wrote:
> We use the DS approach to deploy our custom servlets. For static files we use 
> the default file serving mechanisms, and for us using RFC66-style bundles to 
> serve the static files is quite handy.
> 
> Try importing this project http://blog.fnord.se/storage/webthing-static.zip 
> for a simple example that serves a simple static file. No code required, just 
> meta-data :)
> 
> If you really want to use the DS approach to serve static files you need to 
> instantiate something that can serve the files; probably a ResourceHandler. 
> The problem there is that ResourceHandler does not extend ContextHandler 
> which is what jetty-osgi-boot is looking for. If I were you I'd just try to 
> expose the static files using some other method, but if you figure something 
> out, post it here; I'm curious!
> 
> // Henrik
> 
> On Feb 17, 2011, at 17:14 , Mitul Adhia wrote:
> 
> > Hi Henrick ,
> >
> > In my case jetty is embedded in equinox container and i do not have WEB-INF 
> > folder structure anywhere in my project. So definetly i wont be using 
> > web.xml  to register the servlet / point to any static html files . Also i 
> > do not have war files which can be deployed on my jetty server ... basicaly 
> > i was using the DS approach which you have explained so far ...
> >
> > In that case how the approch which you pointed out 
> > http://wiki.eclipse.org/Jetty/Feature/Jetty_OSGi#Deployment_of_web-applications_via_OSGi
> > will sufice my requirement . I went through the link but it didn't help me 
> > in my case ...
> >
> > Best Regards,
> > Mitul
> >
> > On Thu, Feb 17, 2011 at 9:29 PM, Henrik Gustafsson 
> > <[email protected]> wrote:
> > There are many ways of doing that.
> >
> > For the static files we serve up, we've created a bundle that contains this 
> > header in the MANIFEST.MF:
> >
> > Web-ContextPath: /
> >
> > We also have a WEB-INF-folder containing a standard web.xml. Our files are 
> > placed relative to the root of the bundle, so immediately inside the bundle 
> > you'll find WEB-INF and index.html (and the other files)
> >
> > A web.xml might look like this:
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> >    xmlns="http://java.sun.com/xml/ns/javaee"; 
> > xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd";
> >    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
> > http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd";
> >    id="WebApp_ID" version="2.5">
> >    <display-name>Webthing</display-name>
> >    <servlet-mapping>
> >        <servlet-name>default</servlet-name>
> >        <url-pattern>/</url-pattern>
> >    </servlet-mapping>
> > </web-app>
> >
> > The osgi boot bundle will pick this up automagically. See 
> > http://wiki.eclipse.org/Jetty/Feature/Jetty_OSGi#Deployment_of_web-applications_via_OSGi
> >  for details.
> >
> > // Henrik
> >
> >
> > On Feb 17, 2011, at 16:40 , Mitul Adhia wrote:
> >
> > > Hi Henrick,
> > >
> > > Yes that was the issue i tried the putting below xml snippet under the 
> > > Handler class difinition
> > >
> > >       <Item>
> > >            <New class="org.eclipse.jetty.server.handler.ResourceHandler">
> > >              <Set name="directoriesListed">true</Set>
> > >              <Set name="welcomeFiles">
> > >                <Array type="String"><Item>index.html</Item></Array>
> > >              </Set>
> > >              <Set name="resourceBase">.</Set>
> > >            </New>
> > >          </Item>
> > >
> > > Now my index.html file is located in different bundle not in the one were 
> > > my jetty.xml file is located . how do i have access to that html file 
> > > using following url
> > > http://localhost:8080/flexui/index.html ....
> > >
> > > Do i need to add any specific handler which would extend the resource 
> > > handle and take the html file from that bundle ...???
> > >
> > > Best Regards,
> > > mitul
> > >
> > >
> > > On Thu, Feb 17, 2011 at 8:58 PM, Henrik Gustafsson 
> > > <[email protected]> wrote:
> > > I think you are overwriting the old handler attribute.
> > >
> > > Say, do you perhaps have two <Set name="handler"></Set>-sections in your 
> > > jetty.xml? If so you should probably merge contents of the <Array>-tags 
> > > instead.
> > >
> > > // Henrik
> > >
> > > On Feb 17, 2011, at 16:12 , Mitul Adhia wrote:
> > >
> > >> Hi Henrik,
> > >>
> > >> Was trying to append the content of jetty.filserver.xml in jetty.xml  so 
> > >> default configuration for resource file can also be added along with the 
> > >> context . But after adding this i again started getting the exception 
> > >> given below .. yes after adding the xml snippet the Server class was 
> > >> configure file resource value .
> > >>
> > >> jettyetc=etc/jetty.xml
> > >> 2011-02-17 18:09:10.315:INFO::Configuring the default jetty server with 
> > >> bundleentry://68.fwk25567987/etc/jetty.xml
> > >> java.lang.IllegalStateException: ERROR: No ContextHandlerCollection or 
> > >> OSGiAppProvider configured
> > >>      at 
> > >> org.eclipse.jetty.osgi.boot.internal.serverfactory.ServerInstanceWrapper.init(ServerInstanceWrapper.java:333)
> > >>
> > >>
> > >> Content from jetty.resource.xml file
> > >>
> > >>   <Set name="handler">
> > >>    <New class="org.eclipse.jetty.server.handler.HandlerList">
> > >>      <Set name="handlers">
> > >>        <Array type="org.eclipse.jetty.server.Handler">
> > >>          <Item>
> > >>            <New class="org.eclipse.jetty.server.handler.ResourceHandler">
> > >>              <Set name="directoriesListed">true</Set>
> > >>              <Set name="welcomeFiles">
> > >>                <Array type="String"><Item>index.html</Item></Array>
> > >>              </Set>
> > >>              <Set name="resourceBase">.</Set>
> > >>            </New>
> > >>          </Item>
> > >>          <Item>
> > >>            <New class="org.eclipse.jetty.server.handler.DefaultHandler">
> > >>            </New>
> > >>          </Item>
> > >>        </Array>
> > >>      </Set>
> > >>    </New>
> > >>  </Set>
> > >>
> > >>
> > >> Now the question is how do i do the configuration for fileresource . The 
> > >> index.html file is located in bunlde where WebThing.java which extends 
> > >> ServletContexthandler is located ..
> > >>
> > >> Best Regards,
> > >> mitul
> > >>
> > >> On Thu, Feb 17, 2011 at 8:06 PM, Henrik Gustafsson 
> > >> <[email protected]> wrote:
> > >>
> > >> On Feb 17, 2011, at 15:28 , Mitul Adhia wrote:
> > >>
> > >> > Hi Henrik,
> > >> >
> > >> > Thanks a ton it works now !!!!!
> > >> >
> > >> > I have one more question to configure ssl or resource file there are 
> > >> > corresponding xml files i.e jetty-ssl.xml & jetty-fileserver.xml do i 
> > >> > need to add them in the same location where my jetty.xml is available 
> > >> > or i can append the data which are available in both the xml's in 
> > >> > single jetty.xml.... ? What is your suggestion ?
> > >>
> > >> I just added an ssl connector into jetty.xml:
> > >>
> > >> <Call name="addConnector">
> > >>    <Arg>
> > >>        <New 
> > >> class="org.eclipse.jetty.server.ssl.SslSelectChannelConnector">
> > >>            <Set name="host">
> > >>                <SystemProperty name="jetty.ssl.host" default="0.0.0.0" />
> > >>            </Set>
> > >>            <Set name="Port">
> > >>                <SystemProperty name="jetty.ssl.port" default="8443" />
> > >>            </Set>
> > >>            <Set name="maxIdleTime">30000</Set>
> > >>            <Set name="Acceptors">2</Set>
> > >>            <Set name="AcceptQueueSize">100</Set>
> > >>            <Set name="Password">
> > >>                <SystemProperty name="jetty.ssl.password" default="..." />
> > >>            </Set>
> > >>            <Set name="Keystore">
> > >>                <SystemProperty name="jetty.ssl.keystore" default="..." />
> > >>            </Set>
> > >>            <Set name="KeystoreType">
> > >>                <SystemProperty name="jetty.ssl.keystoretype" 
> > >> default="..." />
> > >>            </Set>
> > >>            <Set name="KeyPassword">
> > >>                <SystemProperty name="jetty.ssl.keypassword" 
> > >> default="..." />
> > >>            </Set>
> > >>            <Set name="Truststore">
> > >>                <SystemProperty name="jetty.ssl.keystore" default="..." />
> > >>            </Set>
> > >>            <Set name="TrustPassword">
> > >>                <SystemProperty name="jetty.ssl.password" default="..." />
> > >>            </Set>
> > >>            <Set name="TruststoreType">
> > >>                <SystemProperty name="jetty.ssl.keystoretype" 
> > >> default="..." />
> > >>            </Set>
> > >>        </New>
> > >>    </Arg>
> > >> </Call>
> > >>
> > >> We use the jetty.ssl.* properties to override the default values when we 
> > >> develop. The values used in deployment are set as defaults. Note that we 
> > >> reuse the jetty.ssl.keystore* stuff, which you might or might not want 
> > >> to do.
> > >>
> > >> > If answer is yes do i need to create customize handler for 
> > >> > resourcefile handler / ssl connector the way it was develop for 
> > >> > servlet context handler ?
> > >> > Something like this
> > >> >
> > >> > MyFileHandlet extends
> > >> > MySSLConnector  extends SslSelectChannelConnector .
> > >>
> > >> Nope, shouldn't be necessary.
> > >>
> > >> // Henrik
> > >> _______________________________________________
> > >> jetty-users mailing list
> > >> [email protected]
> > >> https://dev.eclipse.org/mailman/listinfo/jetty-users
> > >>
> > >> _______________________________________________
> > >> jetty-users mailing list
> > >> [email protected]
> > >> https://dev.eclipse.org/mailman/listinfo/jetty-users
> > >
> > >
> > > _______________________________________________
> > > jetty-users mailing list
> > > [email protected]
> > > https://dev.eclipse.org/mailman/listinfo/jetty-users
> > >
> > >
> > > _______________________________________________
> > > jetty-users mailing list
> > > [email protected]
> > > https://dev.eclipse.org/mailman/listinfo/jetty-users
> >
> > _______________________________________________
> > jetty-users mailing list
> > [email protected]
> > https://dev.eclipse.org/mailman/listinfo/jetty-users
> >
> > _______________________________________________
> > jetty-users mailing list
> > [email protected]
> > https://dev.eclipse.org/mailman/listinfo/jetty-users
> 
> _______________________________________________
> jetty-users mailing list
> [email protected]
> https://dev.eclipse.org/mailman/listinfo/jetty-users
> 
> _______________________________________________
> jetty-users mailing list
> [email protected]
> https://dev.eclipse.org/mailman/listinfo/jetty-users

_______________________________________________
jetty-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/jetty-users

Reply via email to