Re: [jetty-users] Customizing 404 response for virtual hosts
On 06/08/2015 13:25, John English wrote: It would appear from my experiments that when there are multiple setHandler blocks defining webapps all mapped to /, the last one wins if the virtual host lists are not disjoint. If I have one accepting 127.0.0.1 (A) and another without a VH list (B), specifying A then B means that B always responds. If I reverse the order (B then A), A accepts 127.0.0.1 correctly, but generates a default 404 page for 127.0.0.2 rather than invoking B. Since no-one has been able to tell me how to solve my problem, I've eventually stopped using virtual hosts completely due to the apparent inability of Jetty to let you customise the 404 response to an invalid hostname, and instead I have added a filter to the servlet chain that inspects the hostname before honoring the request, and then if it's not in the aproved hostname list I can process it however I like. Clunky, but it has the advantage of actually working. Maybe it's different in Jetty 9 (I plan to upgrade soon, promise) but once again the docs don't cover this particular problem so I'm not that optimistic it'll be any easier. -- John English ___ jetty-users mailing list jetty-users@eclipse.org To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/jetty-users
Re: [jetty-users] Alternative of HTML in Jetty9
Hi Joakim, I'm migrating the application from Jetty 6.1.19 to Jetty-9.1.1. I have few doubts in the code used to start the server. The existing code in Jetty6 uses webAppDeployer to deploy but the same class is replaced by webAppProvider in jetty-9. In the below code from Jetty6 , when I change to Jetty 9, I have few doubts written near to code lines, this.jettyWebServer = new Server(); --- ThreadPool threadPool = new ThreadPool(threadPoolSize); - ThreadPool class not available .. only ThreadPool interface in Jetty9( can we use QueueThreadPool in jetty9) jettyWebServer.setThreadPool(threadPool); Connector connector = new SelectChannelConnector(); -- SelectChannelConnector not avialble in jetty6, any alternative for this class ? connector.setPort(port); -- connector will be ServerConnector ? this.jettyWebServer.setConnectors(new Connector[]{connector}); WebAppDeployer webAppDeployer = new WebAppDeployer(); - webAppProvider ? webAppDeployer.setContexts(this.jettyWebServer); webAppDeployer.setWebAppDir(warpath); -- no method in webAppProvider to set WebAppDir webAppDeployer.setExtract(true); webAppDeployer.setParentLoaderPriority(true); webAppDeployer.start(); this.jettyWebServer.setStopAtShutdown(true); this.jettyWebServer.setSendServerVersion(false); this.jettyWebServer.start(); this.jettyWebServer.join(); Is the code above is enough to start Jetty-9 ?. or anything missing ?. Thanks, Arun On Fri, Aug 7, 2015 at 10:07 PM, Joakim Erdfelt joa...@webtide.com wrote: Found an api reference on a 3rd party site. http://api.dpml.net/jetty/5.1.6/org/mortbay/html/package-tree.html Yeah, those don't exist in Jetty 9 (or Jetty 7 or Jetty 8 for that matter) The oldest copy of the code I could find is from 2007. https://github.com/jetty-project/codehaus-jetty6/tree/jetty-6.1.7/modules/html/src/main/java/org/mortbay/html You might have some luck copying those files into place on your own project and using them (with some modifications for references to jetty utility classes) OR, just use any of the hundreds of html templating libraries for Java Servlets out there. Joakim Erdfelt / joa...@webtide.com On Fri, Aug 7, 2015 at 9:30 AM, Joakim Erdfelt joa...@webtide.com wrote: Not sure what the org.mortbay.html classes are. The existence of that namespace/classes tree is news to most of us. What do they do? Joakim Erdfelt / joa...@webtide.com On Fri, Aug 7, 2015 at 9:12 AM, Arun Kumar arunkumars...@gmail.com wrote: Hi Team, While migrating the jetty5 to jetty9, I need to rewrite HTML code from org.mortbay.html classes like table, page, block etc to similar in jetty9. what is the alternative to html classes in jetty9 ?. can I use servlets in jetty 9 to implement the same logic ? Thanks,, Arun ___ jetty-users mailing list jetty-users@eclipse.org To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/jetty-users ___ jetty-users mailing list jetty-users@eclipse.org To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/jetty-users ___ jetty-users mailing list jetty-users@eclipse.org To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/jetty-users
Re: [jetty-users] Customizing 404 response for virtual hosts
John, Your jetty.xml you posted does not look correctly configured. You should have a HandlerList containing a ContextHandlerCollection (which contains your webapp with its virtual host setup) and a DefaultHandler. If you webapp does not answer the request because the virtual hosts don't match, the request will fall through the HandlerList to the DefaultHandler. Now, the DefaultHandler is not particularly customizable, however you could easily write your own handler to pump out the kind of error page you want. Jan On 16 August 2015 at 20:23, John English john.fore...@gmail.com wrote: On 06/08/2015 13:25, John English wrote: It would appear from my experiments that when there are multiple setHandler blocks defining webapps all mapped to /, the last one wins if the virtual host lists are not disjoint. If I have one accepting 127.0.0.1 (A) and another without a VH list (B), specifying A then B means that B always responds. If I reverse the order (B then A), A accepts 127.0.0.1 correctly, but generates a default 404 page for 127.0.0.2 rather than invoking B. Since no-one has been able to tell me how to solve my problem, I've eventually stopped using virtual hosts completely due to the apparent inability of Jetty to let you customise the 404 response to an invalid hostname, and instead I have added a filter to the servlet chain that inspects the hostname before honoring the request, and then if it's not in the aproved hostname list I can process it however I like. Clunky, but it has the advantage of actually working. Maybe it's different in Jetty 9 (I plan to upgrade soon, promise) but once again the docs don't cover this particular problem so I'm not that optimistic it'll be any easier. -- John English ___ jetty-users mailing list jetty-users@eclipse.org To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/jetty-users ___ jetty-users mailing list jetty-users@eclipse.org To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/jetty-users