Thanks for you reply Achim, It sounds like the easiest would be to use a ResourceServlet. Looking at the code, it seems like the ResourceServlet checks its private member variable "mimeTypes" for mapping extensions to mime types (after it has asked the HttpContext. However, I can't see any way to actually add a mime type mapping to the ResourceServlet. Had the ResourceServlet had a method to just add mime type mappings this would be perfect but I can't see how this would be possible. So I think I need the combination of a ResourceServlet AND a custom HttpContext.
I assume that I have to implement my own HttpContext since there is no method in the HttpContext to add mime type mappings either. What is the best practice here? Should I encapsulate the default HttpContext (and delegate calls to it) and implement my own version of the getMimeType() method? Thanks, /Bengt 2012/9/14 Achim Nierbeck <[email protected]> > Hi Bengt, > > if I'm not totally wrong you probably just need to make sure you have > a httpContext which returns the right mimeType. > Or you have to use a customized ResourceServlet. > For Example take the ResourceServlet at [1] it questions the > httpContext for the mime types. > If you register your own HttpContext instead of the default one, you > should be safe here. > See the activator of the HS sample [2], a default httpContext is > registered. > If you use the whiteboard extender it's the same, take a look at [3]. > > regards, Achim > > [1] - > https://github.com/ops4j/org.ops4j.pax.web/blob/master/pax-web-jetty/src/main/java/org/ops4j/pax/web/service/jetty/internal/ResourceServlet.java > [2] - > https://github.com/ops4j/org.ops4j.pax.web/blob/master/samples/helloworld-hs/src/main/java/org/ops4j/pax/web/samples/helloworld/hs/internal/Activator.java#L55 > [3] - > https://github.com/ops4j/org.ops4j.pax.web/blob/master/samples/whiteboard/src/main/java/org/ops4j/pax/web/extender/samples/whiteboard/internal/Activator.java#L70 > > 2012/9/14 Bengt Rodehav <[email protected]>: > > OK - thanks Achim, > > > > /Bengt > > > > > > 2012/9/14 Achim Nierbeck <[email protected]> > >> > >> Hi Bengt, > >> > >> I'd have to check, so maybe I have an answer to this the coming week :) > >> > >> regards, Achim > >> > >> 2012/9/13 Bengt Rodehav <[email protected]>: > >> > Hello Achim, > >> > > >> > I don't use a war. I use a web container and register my servlet > >> > programatically - so no web.xml. How can this be done > programatically? > >> > > >> > /Bengt > >> > > >> > > >> > 2012/9/12 Achim Nierbeck <[email protected]> > >> >> > >> >> Hi Bengt, > >> >> > >> >> I just stepped through the war itest [1] and the mime type for the > png > >> >> was returned successfully. > >> >> Besides that it should be straight forward to define a mime type > >> >> mapping in the web.xml. [2] > >> >> If you need it for the whiteboard extender this could be a bit more > >> >> tricky. > >> >> > >> >> regards, Achim > >> >> > >> >> [1] - > >> >> > >> >> > https://github.com/ops4j/org.ops4j.pax.web/blob/master/itest/src/test/java/org/ops4j/pax/web/itest/WarIntegrationTest.java#L112 > >> >> [2] - > >> >> > >> >> > http://www.java2s.com/Code/JavaAPI/javax.servlet.http/webxmlmimemapping.htm > >> >> > >> >> 2012/9/12 Bengt Rodehav <[email protected]>: > >> >> > Hi Achim, > >> >> > > >> >> > No sweat - I understand that you're a busy man. Also, this is not > >> >> > critical > >> >> > for me after I resolved my real problem with the template. > >> >> > > >> >> > The only way I've tested is to have my Pax-Web serve static files > >> >> > contained > >> >> > in my bundle. I noticed that for my template files (with extension > >> >> > .ejs), I > >> >> > don't get a Content-Type at all in the response. This is easy to > see > >> >> > in > >> >> > both > >> >> > Chrome and Firefox. Also, in Firefox console I get errors about > >> >> > invalid > >> >> > XML. > >> >> > Seems like the default handling on the browser side is to treat the > >> >> > files as > >> >> > XML if no Content-Type is specified (just my guess). > >> >> > > >> >> > Now that I think of it, I use the "steal" functionality provided by > >> >> > Javascript MVC. I think that "steal" uses AJAX request to load the > >> >> > templates. That could be the reason why XML seems to be assumed. > >> >> > > >> >> > Nonetheless, I think documenting how to map file extensions to > >> >> > Content-Type > >> >> > using Pax-Web would be a good thing (I'm hoping it is supported). > >> >> > > >> >> > /Bengt > >> >> > > >> >> > > >> >> > 2012/9/11 Achim Nierbeck <[email protected]> > >> >> >> > >> >> >> Hi Bengt, > >> >> >> > >> >> >> sorry I'm quite busy right now. > >> >> >> Do you have a simple test for me to reproduce, wich I can use for > >> >> >> the > >> >> >> itests? > >> >> >> To my understanding it should work right away so it might possibly > >> >> >> be a > >> >> >> bug. > >> >> >> > >> >> >> regards, Achim > >> >> >> > >> >> >> > >> >> >> 2012/9/10 Bengt Rodehav <[email protected]>: > >> >> >> > As it turns out, the Content-Type wasn't the root of my > problems. > >> >> >> > I > >> >> >> > had > >> >> >> > a > >> >> >> > syntax error in my template (.ejs file) which caused a lot of > >> >> >> > problems > >> >> >> > that > >> >> >> > were hard to detect. > >> >> >> > > >> >> >> > Nevertheless, I would like to specify that ".ejs" files should > >> >> >> > have > >> >> >> > the > >> >> >> > MIME > >> >> >> > type "text/plain" since it is not given any Content-Type at all > >> >> >> > presently. > >> >> >> > Judging from the error messages in Firebug it does seem like the > >> >> >> > browser > >> >> >> > (at > >> >> >> > least Firefox) then tries to interpret it as XML. > >> >> >> > > >> >> >> > Does anyone know how to do this with Pax-Web? > >> >> >> > > >> >> >> > /Bengt > >> >> >> > > >> >> >> > > >> >> >> > 2012/9/6 Bengt Rodehav <[email protected]> > >> >> >> >> > >> >> >> >> I'm using Karar 2.2.8 which includes Pax-Web 1.0.11. I'm using > >> >> >> >> JavascriptMVC and its templating engine. The templates have the > >> >> >> >> extension > >> >> >> >> ".ejs". > >> >> >> >> > >> >> >> >> Until recently this worked fine but I now have lots of problems > >> >> >> >> with > >> >> >> >> this > >> >> >> >> - probably due to "background updates" of my webb browsers. It > >> >> >> >> seems > >> >> >> >> like > >> >> >> >> the web browser tries to interpret the .ejs files as xml and > >> >> >> >> complains > >> >> >> >> that > >> >> >> >> it is not well-formed. The .ejs files do not have a > Content-Type > >> >> >> >> header > >> >> >> >> in > >> >> >> >> the response which probably leads the browser to do its "best > >> >> >> >> guess". > >> >> >> >> > >> >> >> >> How can I tell Pax-Web that files with the extension ".ejs" > shall > >> >> >> >> have > >> >> >> >> the > >> >> >> >> Content-Type "text/plan"? > >> >> >> >> > >> >> >> >> /Bengt > >> >> >> > > >> >> >> > > >> >> >> > > >> >> >> > _______________________________________________ > >> >> >> > general mailing list > >> >> >> > [email protected] > >> >> >> > http://lists.ops4j.org/mailman/listinfo/general > >> >> >> > > >> >> >> > >> >> >> > >> >> >> > >> >> >> -- > >> >> >> > >> >> >> Apache Karaf <http://karaf.apache.org/> Committer & PMC > >> >> >> OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> > >> >> >> Committer & Project Lead > >> >> >> OPS4J Pax for Vaadin > >> >> >> <http://team.ops4j.org/wiki/display/PAXVAADIN/Home> Commiter & > >> >> >> Project > >> >> >> Lead > >> >> >> blog <http://notizblog.nierbeck.de/> > >> >> >> > >> >> >> _______________________________________________ > >> >> >> general mailing list > >> >> >> [email protected] > >> >> >> http://lists.ops4j.org/mailman/listinfo/general > >> >> > > >> >> > > >> >> > > >> >> > _______________________________________________ > >> >> > general mailing list > >> >> > [email protected] > >> >> > http://lists.ops4j.org/mailman/listinfo/general > >> >> > > >> >> > >> >> > >> >> > >> >> -- > >> >> > >> >> Apache Karaf <http://karaf.apache.org/> Committer & PMC > >> >> OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> > >> >> Committer & Project Lead > >> >> OPS4J Pax for Vaadin > >> >> <http://team.ops4j.org/wiki/display/PAXVAADIN/Home> Commiter & > Project > >> >> Lead > >> >> blog <http://notizblog.nierbeck.de/> > >> >> > >> >> _______________________________________________ > >> >> general mailing list > >> >> [email protected] > >> >> http://lists.ops4j.org/mailman/listinfo/general > >> > > >> > > >> > > >> > _______________________________________________ > >> > general mailing list > >> > [email protected] > >> > http://lists.ops4j.org/mailman/listinfo/general > >> > > >> > >> > >> > >> -- > >> > >> Apache Karaf <http://karaf.apache.org/> Committer & PMC > >> OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> > >> Committer & Project Lead > >> OPS4J Pax for Vaadin > >> <http://team.ops4j.org/wiki/display/PAXVAADIN/Home> Commiter & Project > >> Lead > >> blog <http://notizblog.nierbeck.de/> > >> > >> _______________________________________________ > >> general mailing list > >> [email protected] > >> http://lists.ops4j.org/mailman/listinfo/general > > > > > > > > _______________________________________________ > > general mailing list > > [email protected] > > http://lists.ops4j.org/mailman/listinfo/general > > > > > > -- > > Apache Karaf <http://karaf.apache.org/> Committer & PMC > OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> > Committer & Project Lead > OPS4J Pax for Vaadin > <http://team.ops4j.org/wiki/display/PAXVAADIN/Home> Commiter & Project > Lead > blog <http://notizblog.nierbeck.de/> > > _______________________________________________ > general mailing list > [email protected] > http://lists.ops4j.org/mailman/listinfo/general >
_______________________________________________ general mailing list [email protected] http://lists.ops4j.org/mailman/listinfo/general
