simpleweb-support Mailing List for Simple (Page 26)
Brought to you by:
niallg
You can subscribe to this list here.
2004 |
Jan
(1) |
Feb
(4) |
Mar
(2) |
Apr
(14) |
May
(22) |
Jun
(15) |
Jul
(9) |
Aug
(2) |
Sep
(7) |
Oct
(4) |
Nov
(2) |
Dec
(12) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(7) |
Feb
(16) |
Mar
(17) |
Apr
|
May
(12) |
Jun
(4) |
Jul
(22) |
Aug
(50) |
Sep
(8) |
Oct
(23) |
Nov
(9) |
Dec
(50) |
2006 |
Jan
(6) |
Feb
(7) |
Mar
(8) |
Apr
(3) |
May
(13) |
Jun
(4) |
Jul
(2) |
Aug
|
Sep
(1) |
Oct
|
Nov
(6) |
Dec
(7) |
2007 |
Jan
(11) |
Feb
(3) |
Mar
(17) |
Apr
(21) |
May
(9) |
Jun
(4) |
Jul
(6) |
Aug
(1) |
Sep
|
Oct
(8) |
Nov
(14) |
Dec
(3) |
2008 |
Jan
(3) |
Feb
|
Mar
|
Apr
(5) |
May
|
Jun
|
Jul
(4) |
Aug
(4) |
Sep
(15) |
Oct
(9) |
Nov
(6) |
Dec
(2) |
2009 |
Jan
(29) |
Feb
(2) |
Mar
(8) |
Apr
(14) |
May
(4) |
Jun
(13) |
Jul
(5) |
Aug
|
Sep
|
Oct
(4) |
Nov
(3) |
Dec
(7) |
2010 |
Jan
|
Feb
(2) |
Mar
(61) |
Apr
(9) |
May
(10) |
Jun
(9) |
Jul
(10) |
Aug
(7) |
Sep
(15) |
Oct
(5) |
Nov
(2) |
Dec
(3) |
2011 |
Jan
(11) |
Feb
|
Mar
|
Apr
(2) |
May
|
Jun
|
Jul
(3) |
Aug
|
Sep
(4) |
Oct
|
Nov
(6) |
Dec
(9) |
2012 |
Jan
|
Feb
(1) |
Mar
(2) |
Apr
(3) |
May
(2) |
Jun
|
Jul
(17) |
Aug
|
Sep
|
Oct
|
Nov
(10) |
Dec
(5) |
2013 |
Jan
(2) |
Feb
(4) |
Mar
|
Apr
(12) |
May
|
Jun
(5) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(3) |
Dec
(1) |
2014 |
Jan
|
Feb
(2) |
Mar
(6) |
Apr
|
May
|
Jun
(20) |
Jul
(12) |
Aug
(4) |
Sep
(3) |
Oct
(5) |
Nov
|
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2016 |
Jan
(2) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
2017 |
Jan
|
Feb
(2) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Carfield Y. <car...@ca...> - 2005-12-01 09:44:54
|
I try to use simple.http.Request.getInetAddress().getHostName() but it is very slow, is there better alternative? |
From: Brian D. <wic...@gm...> - 2005-11-29 16:09:55
|
I am interested in integrating this myself.. if anyone else is interested let me know.. maybe we can get it working.. doesn't look too hard.. after skimming the doc.. there is only a couple things I don't like.. for example.. I don't like having a file extension for the templates.. ftl stands for "for the lose".. I would much rather let the templates have a 'natural' file extension.. .txt, .html, .xml so that the web server can determine and handle the content type.. However.. I don't want the FreeMakerService to handle all requests.. the thought is that I would ask the FreeMakerService..isTemplate(path) for any file that has a content type of text/* and is under 1 meg.. if it is a template and it hasnt been modified then I would pass it to the FreeMakerService automatically or not.. anyway.. the main point is that I want the web server to handle any requests that are not requests for templates and I want the FreeMakerService to handle any requests that are for templates .. regardless of file extension... cheers! On 11/28/05, Niall Gallagher <gal...@ya...> wrote: > Hi Hu, > > Thanks for this suggestion. I will check it out. > > Niall > > --- hu...@al... wrote: > > > Since the Velocity seems to be officially dead now > > (last release in april > > 2004!) how about freemarker support for simpleweb? > > http://freemarker.sourceforge.net/ > > > > Freemarker is both active and superior to velocity. > > I would feel much more > > secure with simpleweb and the future if it would > > have freemarker support. > > > > > > > > > ------------------------------------------------------- > > This SF.Net email is sponsored by the JBoss Inc. > > Get Certified Today > > Register for a JBoss Training Course. Free > > Certification Exam > > for All Training Attendees Through End of 2005. For > > more info visit: > > > http://ads.osdn.com/?ad_id=3D7628&alloc_id=3D16845&op=3Dclick > > _______________________________________________ > > Simpleweb-Support mailing list > > Sim...@li... > > > https://lists.sourceforge.net/lists/listinfo/simpleweb-support > > > > > Niall Gallagher > > > > __________________________________ > Yahoo! Music Unlimited > Access over 1 million songs. Try it free. > http://music.yahoo.com/unlimited/ > > > ------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. Do you grep through log fi= les > for problems? Stop! Download the new AJAX search engine that makes > searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! > http://ads.osdn.com/?ad_id=3D7637&alloc_id=3D16865&op=3Dclick > _______________________________________________ > Simpleweb-Support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simpleweb-support > |
From: Carfield Y. <car...@ca...> - 2005-11-29 04:12:00
|
On 11/29/05, Brian Davis <wic...@gm...> wrote: > Hmm.. this works... can it be better? > > public class Server > { > public Server(Host host) throws Exception > { > _host =3D host; > > MyLoaderEngine engine =3D new MyLoaderEngine(); > > Iterator it =3D _host.roots(); > > while (it.hasNext()) > { > File root =3D (File) it.next(); > > engine.addContext(new FileContext(root)); > } > > engine.load("directory", > "com.wickedfastsolutions.server.app.DirectoryListingService"); > engine.load("default", > "com.wickedfastsolutions.server.app.WickedfastService"); > > engine.link("*", "default"); > > ProtocolHandler handler =3D ProtocolHandlerFactory.getInstance(en= gine); > > handler =3D new ServerHandler(handler); > > Connection connection =3D ConnectionFactory.getConnection(handler= ); > > connection.connect(new ServerSocket(_host.getPort(), 50, > InetAddress.getByName(_host.getAddress()))); > > System.err.println("Current Time is " + new Date()); > System.err.println("Server is running at " + > _host.getAddress() + " port " + _host.getPort()); > } > > public static void main(String[] args) throws Exception > { > Host host =3D new Host(); > > host.addRoot(new File("test/templates")); > host.addRoot(new File("test/templates2")); > host.setAddress("127.0.0.1"); > host.setPort(2000); > > new Server(host); > } > > public Host getHost() > { > return _host; > } > > private Host _host; > } > > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > public class MyLoaderEngine implements LoaderManager, ResourceEngine > { > public MyLoaderEngine() > { > } > > public void addContext(Context context) > { > try > { > _contexts.add(new LoaderEngine(context)); > } > > catch (IOException ex) > { > throw new RuntimeException(ex.getMessage()); > } > } > > public void update(String name, Loader loader) > { > Iterator it =3D _contexts.iterator(); > > while (it.hasNext()) > { > LoaderEngine engine =3D (LoaderEngine) it.next(); > > engine.update(name, loader); > } > } > > public void remove(String name) > { > Iterator it =3D _contexts.iterator(); > > while (it.hasNext()) > { > LoaderEngine engine =3D (LoaderEngine) it.next(); > > engine.remove(name); > } > } > > public void load(String name, String className) throws LoadingExceptio= n > { > Iterator it =3D _contexts.iterator(); > > while (it.hasNext()) > { > LoaderEngine engine =3D (LoaderEngine) it.next(); > > engine.load(name, className); > } > } > > public void load(String name, String className, Object data) throws > LoadingException > { > Iterator it =3D _contexts.iterator(); > > while (it.hasNext()) > { > LoaderEngine engine =3D (LoaderEngine) it.next(); > > engine.load(name, className, data); > } > } > > public void unload(String name) > { > Iterator it =3D _contexts.iterator(); > > while (it.hasNext()) > { > LoaderEngine engine =3D (LoaderEngine) it.next(); > > engine.unload(name); > } > } > > public void link(String pattern, String name) > { > Iterator it =3D _contexts.iterator(); > > while (it.hasNext()) > { > LoaderEngine engine =3D (LoaderEngine) it.next(); > > engine.link(pattern, name); > } > } > > public void link(String pattern, String name, int pos) > { > Iterator it =3D _contexts.iterator(); > > while (it.hasNext()) > { > LoaderEngine engine =3D (LoaderEngine) it.next(); > > engine.link(pattern, name, pos); > } > } > > public void unlink(String pattern) > { > Iterator it =3D _contexts.iterator(); > > while (it.hasNext()) > { > LoaderEngine engine =3D (LoaderEngine) it.next(); > > engine.unlink(pattern); > } > } > > public void unlink(Match match) > { > Iterator it =3D _contexts.iterator(); > > while (it.hasNext()) > { > LoaderEngine engine =3D (LoaderEngine) it.next(); > > engine.unlink(match); > } > } > > public synchronized Resource resolve(String target) > { > Iterator it =3D _contexts.iterator(); > > while (it.hasNext()) > { > try > { > LoaderEngine engine =3D (LoaderEngine) it.next(); > > String path =3D engine.context.getRequestPath(target); > String name =3D engine.resolver.resolve(path); > > if (engine.registry.contains(name)) > { > Context context =3D engine.context; > > File file =3D context.getLocator().getFile(target); > > if (!file.isHidden() && file.canRead()) > { > return engine.registry.retrieve(name); > } > } > } > > catch (LocateException ex) > { > } > } > > return new NotFound(new FileContext(new File("/"))); > } > > private class NotFound extends BasicResource { > public NotFound(Context context) { > this.context =3D context; > } > public void process(Request req, Response resp) { > handle(req, resp, new StatusReport(404)); > } > } > > private ArrayList _contexts =3D new ArrayList(); > } > > Thanks! > > > On 11/28/05, Niall Gallagher <gal...@ya...> wrote: > > Hi Brian, > > > > No, you do not have to rewrite the LoaderEngine to do > > this. What you can do is extend it in much the same > > way as the MapperEngine does. If you wish to add > > multiple paths to the classpath used by the loader > > engine then you can delegate to the following > > constructor. > > > > LoaderEngine(Context context, URL[] codebase); > > > > Simply add additional URLs in the form > > file:///a/b/c/path, etc. If you would like the Context > > to find files from multiple roots, then you should > > consider using the Locator. The locator performs a > > search for files from multiple locations. I typically > > use this for loading configuration files. The > > simple.http.serve.FileLocator is good for this. For > > example you could use: > > > > Locator loc =3D context.getLocator(); > > > > loc.getFile("/my/file.txt"); > > > > The file is searched for within all roots specified to > > the FileLocator. To increase the number of roots you > > can do the following: > > > > new FileLocator(new File[]{new File("root1"), new > > File("root2")}); > > > > Also you will have to extend the FileContext like > > follows: > > > > class MyFileContext extends FileContext { > > > > private Locator loc; > > > > public MyFileContext(File base, Locator loc) { > > super(base); > > this.loc =3D loc; > > } > > > > public Locator getLocator() { > > return loc; > > } > > } > > > > Hope this helps. > > > > Niall > > > > > > --- Brian Davis <wic...@gm...> wrote: > > > > > Hi > > > > > > I am using a FileContext with a LoaderEngine to set > > > the 'root' of the > > > web server. > > > > > > FileContext context =3D new FileContext(new > > > File("webserverroot/")); > > > > > > LoaderEngine engine =3D new > > > LoaderEngine(context); > > > > > > > > > This works just dandy.. but I would like to support > > > the concept of > > > multiple server roots... > > > > > > Do I have to rewrite the LoaderEngine to accomplish > > > this? > > > > > > LoaderEngine engine =3D new LoaderEngine(); > > > > > > engine.addContext(new FileContext(new > > > File("root1")); > > > engine.addContext(new FileContext(new > > > File("root2")); > > > > > > Also.. would be nice if the resolver tried to > > > resolve in root1.. then > > > root2.. then fail.. > > > > > > Any help would be much appreciated.. > > > > > > Thanks! > > > > > > Brian > > > > > > > > > > > ------------------------------------------------------- > > > This SF.net email is sponsored by: Splunk Inc. Do > > > you grep through log files > > > for problems? Stop! Download the new AJAX search > > > engine that makes > > > searching your log files as easy as surfing the > > > web. DOWNLOAD SPLUNK! > > > http://ads.osdn.com/?ad_idv37&alloc_id=16865&op=3Dclick > > > _______________________________________________ > > > Simpleweb-Support mailing list > > > Sim...@li... > > > > > https://lists.sourceforge.net/lists/listinfo/simpleweb-support > > > > > > > > > Niall Gallagher > > > > > > > > > > __________________________________ > > Yahoo! Mail - PC Magazine Editors' Choice 2005 > > http://mail.yahoo.com > > > > > > ------------------------------------------------------- > > This SF.net email is sponsored by: Splunk Inc. Do you grep through log = files > > for problems? Stop! Download the new AJAX search engine that makes > > searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! > > http://ads.osdn.com/?ad_id=3D7637&alloc_id=3D16865&op=3Dclick > > _______________________________________________ > > Simpleweb-Support mailing list > > Sim...@li... > > https://lists.sourceforge.net/lists/listinfo/simpleweb-support > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. Do you grep through log fi= les > for problems? Stop! Download the new AJAX search engine that makes > searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! > http://ads.osdn.com/?ad_idv37&alloc_id=16865&opclick > _______________________________________________ > Simpleweb-Support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simpleweb-support > |
From: Carfield Y. <car...@gm...> - 2005-11-29 03:52:07
|
> engine.addContext(new FileContext(new File("root1")); > engine.addContext(new FileContext(new File("root2")); > I have thought of doing similar thing, but what in my mind is to extend java.io.File() object (which is not final) which accepting multiple files at constructor, then overload approach method, like list() and listFiles() . I think this should work |
From: Brian D. <wic...@gm...> - 2005-11-28 21:21:33
|
Hmm.. this works... can it be better? public class Server { public Server(Host host) throws Exception { _host =3D host; MyLoaderEngine engine =3D new MyLoaderEngine(); Iterator it =3D _host.roots(); while (it.hasNext()) { File root =3D (File) it.next(); engine.addContext(new FileContext(root)); } engine.load("directory", "com.wickedfastsolutions.server.app.DirectoryListingService"); engine.load("default", "com.wickedfastsolutions.server.app.WickedfastService"); engine.link("*", "default"); ProtocolHandler handler =3D ProtocolHandlerFactory.getInstance(engi= ne); handler =3D new ServerHandler(handler); Connection connection =3D ConnectionFactory.getConnection(handler); connection.connect(new ServerSocket(_host.getPort(), 50, InetAddress.getByName(_host.getAddress()))); System.err.println("Current Time is " + new Date()); System.err.println("Server is running at " + _host.getAddress() + " port " + _host.getPort()); } public static void main(String[] args) throws Exception { Host host =3D new Host(); host.addRoot(new File("test/templates")); host.addRoot(new File("test/templates2")); host.setAddress("127.0.0.1"); host.setPort(2000); new Server(host); } public Host getHost() { return _host; } private Host _host; } =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D public class MyLoaderEngine implements LoaderManager, ResourceEngine { public MyLoaderEngine() { } public void addContext(Context context) { try { _contexts.add(new LoaderEngine(context)); } catch (IOException ex) { throw new RuntimeException(ex.getMessage()); } } public void update(String name, Loader loader) { Iterator it =3D _contexts.iterator(); while (it.hasNext()) { LoaderEngine engine =3D (LoaderEngine) it.next(); engine.update(name, loader); } } public void remove(String name) { Iterator it =3D _contexts.iterator(); while (it.hasNext()) { LoaderEngine engine =3D (LoaderEngine) it.next(); engine.remove(name); } } public void load(String name, String className) throws LoadingException { Iterator it =3D _contexts.iterator(); while (it.hasNext()) { LoaderEngine engine =3D (LoaderEngine) it.next(); engine.load(name, className); } } public void load(String name, String className, Object data) throws LoadingException { Iterator it =3D _contexts.iterator(); while (it.hasNext()) { LoaderEngine engine =3D (LoaderEngine) it.next(); engine.load(name, className, data); } } public void unload(String name) { Iterator it =3D _contexts.iterator(); while (it.hasNext()) { LoaderEngine engine =3D (LoaderEngine) it.next(); engine.unload(name); } } public void link(String pattern, String name) { Iterator it =3D _contexts.iterator(); while (it.hasNext()) { LoaderEngine engine =3D (LoaderEngine) it.next(); engine.link(pattern, name); } } public void link(String pattern, String name, int pos) { Iterator it =3D _contexts.iterator(); while (it.hasNext()) { LoaderEngine engine =3D (LoaderEngine) it.next(); engine.link(pattern, name, pos); } } public void unlink(String pattern) { Iterator it =3D _contexts.iterator(); while (it.hasNext()) { LoaderEngine engine =3D (LoaderEngine) it.next(); engine.unlink(pattern); } } public void unlink(Match match) { Iterator it =3D _contexts.iterator(); while (it.hasNext()) { LoaderEngine engine =3D (LoaderEngine) it.next(); engine.unlink(match); } } public synchronized Resource resolve(String target) { Iterator it =3D _contexts.iterator(); while (it.hasNext()) { try { LoaderEngine engine =3D (LoaderEngine) it.next(); String path =3D engine.context.getRequestPath(target); String name =3D engine.resolver.resolve(path); if (engine.registry.contains(name)) { Context context =3D engine.context; File file =3D context.getLocator().getFile(target); if (!file.isHidden() && file.canRead()) { return engine.registry.retrieve(name); } } } catch (LocateException ex) { } } return new NotFound(new FileContext(new File("/"))); } private class NotFound extends BasicResource { public NotFound(Context context) { this.context =3D context; } public void process(Request req, Response resp) { handle(req, resp, new StatusReport(404)); } } private ArrayList _contexts =3D new ArrayList(); } Thanks! On 11/28/05, Niall Gallagher <gal...@ya...> wrote: > Hi Brian, > > No, you do not have to rewrite the LoaderEngine to do > this. What you can do is extend it in much the same > way as the MapperEngine does. If you wish to add > multiple paths to the classpath used by the loader > engine then you can delegate to the following > constructor. > > LoaderEngine(Context context, URL[] codebase); > > Simply add additional URLs in the form > file:///a/b/c/path, etc. If you would like the Context > to find files from multiple roots, then you should > consider using the Locator. The locator performs a > search for files from multiple locations. I typically > use this for loading configuration files. The > simple.http.serve.FileLocator is good for this. For > example you could use: > > Locator loc =3D context.getLocator(); > > loc.getFile("/my/file.txt"); > > The file is searched for within all roots specified to > the FileLocator. To increase the number of roots you > can do the following: > > new FileLocator(new File[]{new File("root1"), new > File("root2")}); > > Also you will have to extend the FileContext like > follows: > > class MyFileContext extends FileContext { > > private Locator loc; > > public MyFileContext(File base, Locator loc) { > super(base); > this.loc =3D loc; > } > > public Locator getLocator() { > return loc; > } > } > > Hope this helps. > > Niall > > > --- Brian Davis <wic...@gm...> wrote: > > > Hi > > > > I am using a FileContext with a LoaderEngine to set > > the 'root' of the > > web server. > > > > FileContext context =3D new FileContext(new > > File("webserverroot/")); > > > > LoaderEngine engine =3D new > > LoaderEngine(context); > > > > > > This works just dandy.. but I would like to support > > the concept of > > multiple server roots... > > > > Do I have to rewrite the LoaderEngine to accomplish > > this? > > > > LoaderEngine engine =3D new LoaderEngine(); > > > > engine.addContext(new FileContext(new > > File("root1")); > > engine.addContext(new FileContext(new > > File("root2")); > > > > Also.. would be nice if the resolver tried to > > resolve in root1.. then > > root2.. then fail.. > > > > Any help would be much appreciated.. > > > > Thanks! > > > > Brian > > > > > > > ------------------------------------------------------- > > This SF.net email is sponsored by: Splunk Inc. Do > > you grep through log files > > for problems? Stop! Download the new AJAX search > > engine that makes > > searching your log files as easy as surfing the > > web. DOWNLOAD SPLUNK! > > http://ads.osdn.com/?ad_idv37&alloc_id=16865&op=3Dclick > > _______________________________________________ > > Simpleweb-Support mailing list > > Sim...@li... > > > https://lists.sourceforge.net/lists/listinfo/simpleweb-support > > > > > Niall Gallagher > > > > > __________________________________ > Yahoo! Mail - PC Magazine Editors' Choice 2005 > http://mail.yahoo.com > > > ------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. Do you grep through log fi= les > for problems? Stop! Download the new AJAX search engine that makes > searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! > http://ads.osdn.com/?ad_id=3D7637&alloc_id=3D16865&op=3Dclick > _______________________________________________ > Simpleweb-Support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simpleweb-support > |
From: Niall G. <gal...@ya...> - 2005-11-28 17:45:32
|
Hi Hu, Thanks for this suggestion. I will check it out. Niall --- hu...@al... wrote: > Since the Velocity seems to be officially dead now > (last release in april > 2004!) how about freemarker support for simpleweb? > http://freemarker.sourceforge.net/ > > Freemarker is both active and superior to velocity. > I would feel much more > secure with simpleweb and the future if it would > have freemarker support. > > > > ------------------------------------------------------- > This SF.Net email is sponsored by the JBoss Inc. > Get Certified Today > Register for a JBoss Training Course. Free > Certification Exam > for All Training Attendees Through End of 2005. For > more info visit: > http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click > _______________________________________________ > Simpleweb-Support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simpleweb-support > Niall Gallagher __________________________________ Yahoo! Music Unlimited Access over 1 million songs. Try it free. http://music.yahoo.com/unlimited/ |
From: Niall G. <gal...@ya...> - 2005-11-28 17:40:30
|
Hi Brian, No, you do not have to rewrite the LoaderEngine to do this. What you can do is extend it in much the same way as the MapperEngine does. If you wish to add multiple paths to the classpath used by the loader engine then you can delegate to the following constructor. LoaderEngine(Context context, URL[] codebase); Simply add additional URLs in the form file:///a/b/c/path, etc. If you would like the Context to find files from multiple roots, then you should consider using the Locator. The locator performs a search for files from multiple locations. I typically use this for loading configuration files. The simple.http.serve.FileLocator is good for this. For example you could use: Locator loc = context.getLocator(); loc.getFile("/my/file.txt"); The file is searched for within all roots specified to the FileLocator. To increase the number of roots you can do the following: new FileLocator(new File[]{new File("root1"), new File("root2")}); Also you will have to extend the FileContext like follows: class MyFileContext extends FileContext { private Locator loc; public MyFileContext(File base, Locator loc) { super(base); this.loc = loc; } public Locator getLocator() { return loc; } } Hope this helps. Niall --- Brian Davis <wic...@gm...> wrote: > Hi > > I am using a FileContext with a LoaderEngine to set > the 'root' of the > web server. > > FileContext context = new FileContext(new > File("webserverroot/")); > > LoaderEngine engine = new > LoaderEngine(context); > > > This works just dandy.. but I would like to support > the concept of > multiple server roots... > > Do I have to rewrite the LoaderEngine to accomplish > this? > > LoaderEngine engine = new LoaderEngine(); > > engine.addContext(new FileContext(new > File("root1")); > engine.addContext(new FileContext(new > File("root2")); > > Also.. would be nice if the resolver tried to > resolve in root1.. then > root2.. then fail.. > > Any help would be much appreciated.. > > Thanks! > > Brian > > > ------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. Do > you grep through log files > for problems? Stop! Download the new AJAX search > engine that makes > searching your log files as easy as surfing the > web. DOWNLOAD SPLUNK! > http://ads.osdn.com/?ad_idv37&alloc_id865&op=click > _______________________________________________ > Simpleweb-Support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simpleweb-support > Niall Gallagher __________________________________ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com |
From: Brian D. <wic...@gm...> - 2005-11-28 16:55:11
|
Hi I am using a FileContext with a LoaderEngine to set the 'root' of the web server. FileContext context =3D new FileContext(new File("webserverroot/"))= ; LoaderEngine engine =3D new LoaderEngine(context); This works just dandy.. but I would like to support the concept of multiple server roots... Do I have to rewrite the LoaderEngine to accomplish this? LoaderEngine engine =3D new LoaderEngine(); engine.addContext(new FileContext(new File("root1")); engine.addContext(new FileContext(new File("root2")); Also.. would be nice if the resolver tried to resolve in root1.. then root2.. then fail.. Any help would be much appreciated.. Thanks! Brian |
From: <hu...@al...> - 2005-11-22 20:49:06
|
Since the Velocity seems to be officially dead now (last release in april 2004!) how about freemarker support for simpleweb? http://freemarker.sourceforge.net/ Freemarker is both active and superior to velocity. I would feel much more secure with simpleweb and the future if it would have freemarker support. |
From: Martin N. <mar...@gm...> - 2005-11-22 14:50:56
|
I have now replaced Simpleweb in my application with Jetty because of the SSL problem i got. I believe the setSoTimeout-poller-workaround for SSL connections in Simpleweb made JSSE crash at some points for some reason... /Martin |
From: Martin N. <mar...@gm...> - 2005-10-21 10:40:10
|
This is the code.. very ugly and uncommented and horrible, but it hides the ugliness pretty good. You need to put the files from www.stunnel.org (including the ssl dlls) in the same folder as your app. import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.Writer; import java.net.InetAddress; import java.net.ServerSocket; import java.security.KeyStore; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.security.PrivateKey; import java.security.UnrecoverableKeyException; import java.security.cert.Certificate; import java.security.cert.CertificateException; import java.util.HashMap; import java.util.Iterator; import javax.net.ServerSocketFactory; import javax.net.ssl.KeyManagerFactory; import sun.misc.BASE64Encoder; import sun.reflect.generics.reflectiveObjects.NotImplementedException; public class StunnelServerSocketFactory extends ServerSocketFactory impleme= nts =09=09KeystoreInfo { =09 =09 =09protected String keystore; =09protected String keystorePassword; =09private static HashMap tunnels =3D new HashMap(); =09 =09static { =09=09// Code to shut down STUNNELS when exiting by Ctrl-C or System.exit(.= ..) =09=09Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { =09=09=09public void run() { =09=09=09=09for(Iterator iter =3D tunnels.values().iterator();iter.hasNext(= );) { =09=09=09=09=09Process pr =3D (Process)iter.next(); =09=09=09=09=09pr.destroy(); =09=09=09=09} =09=09=09} =09=09})); =09=09 =09} =09 =09protected ServerSocket setup(int port, int backlog) throws IOException { =09=09Process pr =3D (Process)tunnels.get(new Integer(port)); =09=09if(pr !=3D null) { =09=09=09pr.destroy(); =09=09} =09=09 =09=09String host =3D InetAddress.getLocalHost().getCanonicalHostName(); =09=09ServerSocket ss =3D ServerSocketFactory.getDefault().createServerSocket(0,backlog,InetAddress.g= etByName("127.0.0.1")); =09=09try { =09=09=09createStunnelKeysAndConfig(keystore,keystorePassword,host,port,ss.= getLocalPort()); =09=09} catch (IOException e) { =09=09=09throw e; =09=09} catch (Exception e) { =09=09=09IOException ioe =3D new IOException(e.getMessage()); =09=09=09ioe.setStackTrace(e.getStackTrace()); =09=09=09throw ioe; =09=09} =09=09ProcessBuilder pbt =3D new ProcessBuilder("stunnel.exe"); =09=09pr =3D pbt.start(); =09=09tunnels.put(new Integer(port),pr); =09=09 =09=09return ss; =09} =09@Override =09public ServerSocket createServerSocket() throws IOException { =09=09throw new NotImplementedException(); =09} =09@Override =09public ServerSocket createServerSocket(int port, int backlog, InetAddress addr) throws IOException { =09=09throw new NotImplementedException(); =09} =09@Override =09public ServerSocket createServerSocket(int port, int backlog) throws IOException { =09=09return setup(port,backlog); =09} =09@Override =09public ServerSocket createServerSocket(int port) throws IOException { =09=09return setup(port,0); =09} =09public void setKeystoreInfo(String keystore, String keystorePassword) { =09=09this.keystore =3D keystore; =09=09this.keystorePassword =3D keystorePassword; =09} =09public StunnelServerSocketFactory() { =09=09super(); =09=09// TODO Auto-generated constructor stub =09} =09public static void createStunnelKeysAndConfig(String ksName, String ksPass, String host, int port, int localport) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, FileNotFoundException, IOException, UnrecoverableKeyException { =09=09char tksPass[] =3D ksPass.toCharArray(); =09=09char tctPass[] =3D ksPass.toCharArray(); =09=09KeyStore ks =3D KeyStore.getInstance("JKS"); =09=09ks.load(new FileInputStream(ksName), tksPass); =09=09KeyManagerFactory kmf =3D KeyManagerFactory.getInstance("SunX509"); =09=09kmf.init(ks, tctPass); =09=09 =09=09BASE64Encoder myB64 =3D new BASE64Encoder(); =09=09 =09=09File certificateFile =3D new File(ksName); =09=09ks.load(new FileInputStream(certificateFile), tksPass); =09 =09=09Certificate cert =3D ks.getCertificate(host); =09=09 =09=09PrivateKey privKey =3D (PrivateKey)ks.getKey(host,tctPass); =09=09 =09=09File fPriv =3D new File("tunpriv.pem"); =09=09File fPub =3D new File("tuncert.pem"); =09=09File fStunnel =3D new File("stunnel.conf"); =09 =09=09Writer w =3D new OutputStreamWriter(new FileOutputStream(fPriv),"asci= i"); =09=09 =09=09 =09=09String b64 =3D myB64.encode(privKey.getEncoded()); =09 =09=09w.write("-----BEGIN PRIVATE KEY-----\n"); =09=09w.write(b64); =09=09w.write("\n"); =09=09w.write("-----END PRIVATE KEY-----\n"); =09=09w.close(); =09=09 =09=09w =3D new OutputStreamWriter(new FileOutputStream(fPub),"ascii"); =09=09b64 =3D myB64.encode(cert.getEncoded()); =09=09w.write("-----BEGIN CERTIFICATE-----\n"); =09=09w.write(b64); =09=09w.write("\n"); =09=09w.write("-----END CERTIFICATE-----\n"); =09=09 =09=09w.close(); =09=09w =3D new OutputStreamWriter(new FileOutputStream(fStunnel),"ascii"); =09=09w.write("cert =3D tuncert.pem\n"); =09=09w.write("key =3D tunpriv.pem\n"); =09=09w.write("socket =3D l:TCP_NODELAY=3D1\n"); =09=09w.write("socket =3D r:TCP_NODELAY=3D1\n"); =09=09w.write("[https]\n"); =09=09w.write("accept =3D "+port+"\n"); =09=09w.write("connect =3D 127.0.0.1:"+localport+"\n"); =09=09w.write("TIMEOUTclose =3D 0\n"); =09=09w.close(); =09=09 =09} =09 } On 10/20/05, Niall Gallagher <gal...@ya...> wrote: > Hi Martin, > > I have never used stunnel, however I would like to > have a peek at what you have done. If thats ok... > > Niall > > --- Martin Norrsken <mar...@gm...> wrote: > > > I now run with stunnel www.stunnel.org, my java app > > autogenerates the > > conf-file at startup and also exports the private > > key and public cert > > from the java keystore for stunnels usage. > > > > Apart from the fact that it's now *working* it's > > also about 20 times faster!!! > > > > If anyone is interested in the strange coding I used > > to start stunnel > > with my java app, feel free to email me. > > > > /Martin > > > > > > > ------------------------------------------------------- > > This SF.Net email is sponsored by: > > Power Architecture Resource Center: Free content, > > downloads, discussions, > > and more. > > http://solutions.newsforge.com/ibmarch.tmpl > > _______________________________________________ > > Simpleweb-Support mailing list > > Sim...@li... > > > https://lists.sourceforge.net/lists/listinfo/simpleweb-support > > > > > Niall Gallagher > > > > __________________________________ > Start your day with Yahoo! - Make it your home page! > http://www.yahoo.com/r/hs > > > ------------------------------------------------------- > This SF.Net email is sponsored by: > Power Architecture Resource Center: Free content, downloads, discussions, > and more. http://solutions.newsforge.com/ibmarch.tmpl > _______________________________________________ > Simpleweb-Support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simpleweb-support > |
From: Niall G. <gal...@ya...> - 2005-10-20 19:58:21
|
Hi Martin, I have never used stunnel, however I would like to have a peek at what you have done. If thats ok... Niall --- Martin Norrsken <mar...@gm...> wrote: > I now run with stunnel www.stunnel.org, my java app > autogenerates the > conf-file at startup and also exports the private > key and public cert > from the java keystore for stunnels usage. > > Apart from the fact that it's now *working* it's > also about 20 times faster!!! > > If anyone is interested in the strange coding I used > to start stunnel > with my java app, feel free to email me. > > /Martin > > > ------------------------------------------------------- > This SF.Net email is sponsored by: > Power Architecture Resource Center: Free content, > downloads, discussions, > and more. > http://solutions.newsforge.com/ibmarch.tmpl > _______________________________________________ > Simpleweb-Support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simpleweb-support > Niall Gallagher __________________________________ Start your day with Yahoo! - Make it your home page! http://www.yahoo.com/r/hs |
From: Martin N. <mar...@gm...> - 2005-10-20 17:20:32
|
I now run with stunnel www.stunnel.org, my java app autogenerates the conf-file at startup and also exports the private key and public cert from the java keystore for stunnels usage. Apart from the fact that it's now *working* it's also about 20 times faster= !!! If anyone is interested in the strange coding I used to start stunnel with my java app, feel free to email me. /Martin |
From: Martin N. <mar...@gm...> - 2005-10-20 14:11:55
|
Apparently it's Java 5 SSL implementation that is at fault (??). I switched to using stunnel and running simpleweb on a normal serversocket. It is very annoying though, so I probably need to find a java wrapper for OpenSSL server sockets but I cant seem to find that (as all were discontinued when Java released JSSE). Have you tried to run simpleweb on Java 5 SSL socket? Or just Java 1.4 ? I might change to Java 1.4 but then i have to rewrite much of the source code. Thanks for the help. /Martin On 10/20/05, Niall Gallagher <gal...@ya...> wrote: > Hi Martin, > > If you are sure that the client is closing the > connection, which causes the broken pipe at the server > side then its an SSL/TLS problem. The SSL handshake is > getting mangled or something is corrupt within the SSL > stream. > > HTTP cannot be the problem. HTTPS means HTTP tunneled > through SSL/TLS. The secure socket layer knows nothing > about HTTP so it really does not matter what > configuration you are using in your HTTP messages. > > If you do think it is something with Simple, which I > think is quite unlikely, then I suggest you use > something like the following to debug the response. > Here 443 is the traditional HTTPS port, if you are > listening on some other port then change accordingly. > > openssl s_client -connect my.hostname:443 -state > -debug > > Niall > > --- Martin Norrsken <mar...@gm...> wrote: > > > On 10/19/05, Niall Gallagher > > <gal...@ya...> wrote: > > > Hi Martin, > > > > > > I have used SSL quite frequently in Java 4, and > > never > > > encountered this problem. Although I can say that > > the > > > broken pipe you see on the server side indicates > > that > > > it is the client that is closing the socket. > > > > The client is probably closing the connection > > because it gets an SSL > > "unexpected_message" from the server. Also I only > > get this error > > intermittently, but NOT when i'm using > > javax.net.debug=3Dall (probably > > as this slows down the process considerably). > > > > > > > > If the client is closing the connection then there > > is > > > misconfiguration of the SSL socket. SSL is > > intependant > > > from HTTP, so I can't really say whats happening. > > > > This is what I'm at too. Here's parts of my socket > > and simpleweb > > initialization code: > > -------------------- > > public static void init() { > > try { > > Configuration conf =3D Configuration.getInstance(= ); > > > > > System.setProperty("javax.net.ssl.trustStore",conf.getKeystore()); > > > > > System.setProperty("javax.net.ssl.trustStorePassword",conf.getKeystorePas= sword()); > > > > engine =3D new LoaderEngine(); > > > > > engine.load("logout","norrsken.jcas.web.LogoutService"); > > > > > engine.load("login","norrsken.jcas.web.LoginService"); > > > > > engine.load("success","norrsken.jcas.web.SuccessService"); > > > > > engine.load("validate","norrsken.jcas.web.ValidateService"); > > > > > engine.load("admin","norrsken.jcas.web.AdminService"); > > > > engine.link("/admin","admin"); > > engine.link("/login","login"); > > engine.link("/loginForm","login"); > > engine.link("/logout","logout"); > > engine.link("/success","success"); > > engine.link("/validate","validate"); > > > > WebPageService.register(engine); > > > > try { > > System.setErr(new PrintStream(new > > DoubleOutputStream(System.err,new > > FileOutputStream(conf.getTraceFile())))); > > } catch(Exception e) { > > e.printStackTrace(); > > System.exit(1); > > } > > > > ProtocolHandler handler =3D > > ProtocolHandlerFactory.getInstance(engine); > > Connection connection =3D > > ConnectionFactory.getConnection(handler); > > > > s =3D > > > createSocket(conf.getKeystore(),conf.getKeystorePassword(),conf.getPort()= ); > > > > connection.connect(s); > > > > } catch (Exception e) { > > e.printStackTrace(); > > } > > > > } > > > > public static SSLServerSocket createSocket(String > > ksName, String > > ksPass, int port) throws Exception { > > char tksPass[] =3D ksPass.toCharArray(); > > char tctPass[] =3D ksPass.toCharArray(); > > > > KeyStore ks =3D KeyStore.getInstance("JKS"); > > ks.load(new FileInputStream(ksName), tksPass); > > > > KeyManagerFactory kmf =3D > > KeyManagerFactory.getInstance("SunX509"); > > kmf.init(ks, tctPass); > > > > SSLContext sc =3D SSLContext.getInstance("TLS"); > > sc.init(kmf.getKeyManagers(), null, null); > > SSLServerSocketFactory ssf =3D > > sc.getServerSocketFactory(); > > > > SSLServerSocket ssls =3D (SSLServerSocket) > > ssf.createServerSocket(port); > > //ssls.setEnabledProtocols(new > > String[]{"SSLv3","TLSv1"}); > > return ssls; > > } > > > > > > ------------------ > > Also, i use this code to wrap my handlers: > > ------------------ > > > > public abstract class ExtendedService extends > > BasicService { > > public ExtendedService(Context ctx) { > > super(ctx); > > } > > > > public void handle(final Request req, final > > Response resp) { > > try { > > if(!resp.isCommitted()) resp.reset(); // Tried > > adding this > > resp.setDate("Date",System.currentTimeMillis()); > > resp.set("Server","MyServer/1.x"); > > //resp.set("Connection","close"); // Tried this > > too if it was a HTTP/1.1 prob > > process(req, resp); > > //resp.getOutputStream().flush(); // Tried all > > combinations of > > flush close and commit > > resp.getOutputStream().close(); > > resp.commit(); > > } > > catch(InternetAddressFilter.AccessDeniedException > > ade) { > > Log.log("EXCEPTION: "+ade.toString()); > > ade.printStackTrace(); > > ade.printStackTrace(Log.out); > > handle(req,resp,404); > > } catch (Exception e) { > > Log.log("EXCEPTION: "+e.toString()); > > e.printStackTrace(); > > e.printStackTrace(Log.out); > > handle(req, resp, 500); > > } > > } > > } > > > > > > > > However, I can imagine that if you are using a > > self > > > signed certificate and are prompted to accept from > > > your browser this can take about 5 to 10 seconds, > > and > > > in the meantime there could be a premature close > > of > > > the socket before the SSL handshake protocol has > > > finished. > > > > No this is not the case as ive added the cert to my > > root certs. And it > > mostly happens when loading the images in the > > document i'm first > > loading; i.e. when the requests come close to each > > other or perhaps in > > the same HTTP/1.1 connection (but i've tried > > Connection: close too). > > > > > > > > If there is a premature closure (which is probably > > not > > > the case as you see "broken pipe" messages) I > > would > > > recommend that you increase the timeout that > > Simple is > > > using. To do this make sure the > > > simple.http.poller=3Dsimple.http.GranularPoller. You > > can > > > set this with a -D parameter like so: > > > > > > java > > -Dsimple.http.poller=3Dsimple.http.GranularPoller > > > > > > I hope this solves your problem, or at least > > helps? > > > > Nope. > > > > > > > > Niall > > > > > > --- Martin Norrsken <mar...@gm...> > > wrote: > > > > > > > While using simpleweb with SSL on a Java5 > > platform i > > > > consistently get > > > =3D=3D=3D message truncated =3D=3D=3D > > > Niall Gallagher > > > > __________________________________ > Start your day with Yahoo! - Make it your home page! > http://www.yahoo.com/r/hs > > > ------------------------------------------------------- > This SF.Net email is sponsored by: > Power Architecture Resource Center: Free content, downloads, discussions, > and more. http://solutions.newsforge.com/ibmarch.tmpl > _______________________________________________ > Simpleweb-Support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simpleweb-support > |
From: Niall G. <gal...@ya...> - 2005-10-20 09:27:28
|
Hi Martin, If you are sure that the client is closing the connection, which causes the broken pipe at the server side then its an SSL/TLS problem. The SSL handshake is getting mangled or something is corrupt within the SSL stream. HTTP cannot be the problem. HTTPS means HTTP tunneled through SSL/TLS. The secure socket layer knows nothing about HTTP so it really does not matter what configuration you are using in your HTTP messages. If you do think it is something with Simple, which I think is quite unlikely, then I suggest you use something like the following to debug the response. Here 443 is the traditional HTTPS port, if you are listening on some other port then change accordingly. openssl s_client -connect my.hostname:443 -state -debug Niall --- Martin Norrsken <mar...@gm...> wrote: > On 10/19/05, Niall Gallagher > <gal...@ya...> wrote: > > Hi Martin, > > > > I have used SSL quite frequently in Java 4, and > never > > encountered this problem. Although I can say that > the > > broken pipe you see on the server side indicates > that > > it is the client that is closing the socket. > > The client is probably closing the connection > because it gets an SSL > "unexpected_message" from the server. Also I only > get this error > intermittently, but NOT when i'm using > javax.net.debug=all (probably > as this slows down the process considerably). > > > > > If the client is closing the connection then there > is > > misconfiguration of the SSL socket. SSL is > intependant > > from HTTP, so I can't really say whats happening. > > This is what I'm at too. Here's parts of my socket > and simpleweb > initialization code: > -------------------- > public static void init() { > try { > Configuration conf = Configuration.getInstance(); > > System.setProperty("javax.net.ssl.trustStore",conf.getKeystore()); > > System.setProperty("javax.net.ssl.trustStorePassword",conf.getKeystorePassword()); > > engine = new LoaderEngine(); > > engine.load("logout","norrsken.jcas.web.LogoutService"); > > engine.load("login","norrsken.jcas.web.LoginService"); > > engine.load("success","norrsken.jcas.web.SuccessService"); > > engine.load("validate","norrsken.jcas.web.ValidateService"); > > engine.load("admin","norrsken.jcas.web.AdminService"); > > engine.link("/admin","admin"); > engine.link("/login","login"); > engine.link("/loginForm","login"); > engine.link("/logout","logout"); > engine.link("/success","success"); > engine.link("/validate","validate"); > > WebPageService.register(engine); > > try { > System.setErr(new PrintStream(new > DoubleOutputStream(System.err,new > FileOutputStream(conf.getTraceFile())))); > } catch(Exception e) { > e.printStackTrace(); > System.exit(1); > } > > ProtocolHandler handler = > ProtocolHandlerFactory.getInstance(engine); > Connection connection = > ConnectionFactory.getConnection(handler); > > s = > createSocket(conf.getKeystore(),conf.getKeystorePassword(),conf.getPort()); > > connection.connect(s); > > } catch (Exception e) { > e.printStackTrace(); > } > > } > > public static SSLServerSocket createSocket(String > ksName, String > ksPass, int port) throws Exception { > char tksPass[] = ksPass.toCharArray(); > char tctPass[] = ksPass.toCharArray(); > > KeyStore ks = KeyStore.getInstance("JKS"); > ks.load(new FileInputStream(ksName), tksPass); > > KeyManagerFactory kmf = > KeyManagerFactory.getInstance("SunX509"); > kmf.init(ks, tctPass); > > SSLContext sc = SSLContext.getInstance("TLS"); > sc.init(kmf.getKeyManagers(), null, null); > SSLServerSocketFactory ssf = > sc.getServerSocketFactory(); > > SSLServerSocket ssls = (SSLServerSocket) > ssf.createServerSocket(port); > //ssls.setEnabledProtocols(new > String[]{"SSLv3","TLSv1"}); > return ssls; > } > > > ------------------ > Also, i use this code to wrap my handlers: > ------------------ > > public abstract class ExtendedService extends > BasicService { > public ExtendedService(Context ctx) { > super(ctx); > } > > public void handle(final Request req, final > Response resp) { > try { > if(!resp.isCommitted()) resp.reset(); // Tried > adding this > resp.setDate("Date",System.currentTimeMillis()); > resp.set("Server","MyServer/1.x"); > //resp.set("Connection","close"); // Tried this > too if it was a HTTP/1.1 prob > process(req, resp); > //resp.getOutputStream().flush(); // Tried all > combinations of > flush close and commit > resp.getOutputStream().close(); > resp.commit(); > } > catch(InternetAddressFilter.AccessDeniedException > ade) { > Log.log("EXCEPTION: "+ade.toString()); > ade.printStackTrace(); > ade.printStackTrace(Log.out); > handle(req,resp,404); > } catch (Exception e) { > Log.log("EXCEPTION: "+e.toString()); > e.printStackTrace(); > e.printStackTrace(Log.out); > handle(req, resp, 500); > } > } > } > > > > > However, I can imagine that if you are using a > self > > signed certificate and are prompted to accept from > > your browser this can take about 5 to 10 seconds, > and > > in the meantime there could be a premature close > of > > the socket before the SSL handshake protocol has > > finished. > > No this is not the case as ive added the cert to my > root certs. And it > mostly happens when loading the images in the > document i'm first > loading; i.e. when the requests come close to each > other or perhaps in > the same HTTP/1.1 connection (but i've tried > Connection: close too). > > > > > If there is a premature closure (which is probably > not > > the case as you see "broken pipe" messages) I > would > > recommend that you increase the timeout that > Simple is > > using. To do this make sure the > > simple.http.poller=simple.http.GranularPoller. You > can > > set this with a -D parameter like so: > > > > java > -Dsimple.http.poller=simple.http.GranularPoller > > > > I hope this solves your problem, or at least > helps? > > Nope. > > > > > Niall > > > > --- Martin Norrsken <mar...@gm...> > wrote: > > > > > While using simpleweb with SSL on a Java5 > platform i > > > consistently get > === message truncated === Niall Gallagher __________________________________ Start your day with Yahoo! - Make it your home page! http://www.yahoo.com/r/hs |
From: Martin N. <mar...@gm...> - 2005-10-20 06:20:48
|
On 10/19/05, Niall Gallagher <gal...@ya...> wrote: > Hi Martin, > > I have used SSL quite frequently in Java 4, and never > encountered this problem. Although I can say that the > broken pipe you see on the server side indicates that > it is the client that is closing the socket. The client is probably closing the connection because it gets an SSL "unexpected_message" from the server. Also I only get this error intermittently, but NOT when i'm using javax.net.debug=3Dall (probably as this slows down the process considerably). > > If the client is closing the connection then there is > misconfiguration of the SSL socket. SSL is intependant > from HTTP, so I can't really say whats happening. This is what I'm at too. Here's parts of my socket and simpleweb initialization code: -------------------- =09public static void init() { =09=09try { =09=09=09Configuration conf =3D Configuration.getInstance(); =09=09=09System.setProperty("javax.net.ssl.trustStore",conf.getKeystore()); =09=09=09System.setProperty("javax.net.ssl.trustStorePassword",conf.getKeys= torePassword()); =09=09=09engine =3D new LoaderEngine(); =09=09=09engine.load("logout","norrsken.jcas.web.LogoutService"); =09=09=09engine.load("login","norrsken.jcas.web.LoginService"); =09=09=09engine.load("success","norrsken.jcas.web.SuccessService"); =09=09=09engine.load("validate","norrsken.jcas.web.ValidateService"); =09=09=09engine.load("admin","norrsken.jcas.web.AdminService"); =09=09=09engine.link("/admin","admin"); =09=09=09engine.link("/login","login"); =09=09=09engine.link("/loginForm","login"); =09=09=09engine.link("/logout","logout"); =09=09=09engine.link("/success","success"); =09=09=09engine.link("/validate","validate"); =09=09=09WebPageService.register(engine); =09=09=09try { =09=09=09=09System.setErr(new PrintStream(new DoubleOutputStream(System.err,new FileOutputStream(conf.getTraceFile())))); =09=09=09} catch(Exception e) { =09=09=09=09e.printStackTrace(); =09=09=09=09System.exit(1); =09=09=09} =09=09=09 =09=09=09ProtocolHandler handler =3D ProtocolHandlerFactory.getInstance(eng= ine); =09=09=09Connection connection =3D ConnectionFactory.getConnection(handler)= ; =09=09=09 =09=09=09s =3D createSocket(conf.getKeystore(),conf.getKeystorePassword(),c= onf.getPort()); =09=09=09 =09=09=09connection.connect(s); =09=09 =09=09} catch (Exception e) { =09=09=09e.printStackTrace(); =09=09} =09=09 =09} =09public static SSLServerSocket createSocket(String ksName, String ksPass, int port) throws Exception { =09=09char tksPass[] =3D ksPass.toCharArray(); =09=09char tctPass[] =3D ksPass.toCharArray(); =09=09KeyStore ks =3D KeyStore.getInstance("JKS"); =09=09ks.load(new FileInputStream(ksName), tksPass); =09=09KeyManagerFactory kmf =3D KeyManagerFactory.getInstance("SunX509"); =09=09kmf.init(ks, tctPass); =09=09 =09=09SSLContext sc =3D SSLContext.getInstance("TLS"); =09=09sc.init(kmf.getKeyManagers(), null, null); =09=09SSLServerSocketFactory ssf =3D sc.getServerSocketFactory(); =09=09 =09=09SSLServerSocket ssls =3D (SSLServerSocket) ssf.createServerSocket(por= t); =09=09//ssls.setEnabledProtocols(new String[]{"SSLv3","TLSv1"}); =09=09return ssls; =09} ------------------ Also, i use this code to wrap my handlers: ------------------ public abstract class ExtendedService extends BasicService { =09public ExtendedService(Context ctx) { =09=09super(ctx); =09} =09public void handle(final Request req, final Response resp) { =09=09try { =09=09=09if(!resp.isCommitted()) resp.reset(); // Tried adding this =09=09=09resp.setDate("Date",System.currentTimeMillis()); =09=09=09resp.set("Server","MyServer/1.x"); =09=09=09//resp.set("Connection","close"); // Tried this too if it was a HT= TP/1.1 prob =09=09=09process(req, resp); =09=09=09//resp.getOutputStream().flush(); // Tried all combinations of flush close and commit =09=09=09resp.getOutputStream().close(); =09=09=09resp.commit(); =09=09} catch(InternetAddressFilter.AccessDeniedException ade) { =09=09=09Log.log("EXCEPTION: "+ade.toString()); =09=09=09ade.printStackTrace(); =09=09=09ade.printStackTrace(Log.out); =09=09=09handle(req,resp,404); =09=09} catch (Exception e) { =09=09=09Log.log("EXCEPTION: "+e.toString()); =09=09=09e.printStackTrace(); =09=09=09e.printStackTrace(Log.out); =09=09=09handle(req, resp, 500); =09=09} =09} } > > However, I can imagine that if you are using a self > signed certificate and are prompted to accept from > your browser this can take about 5 to 10 seconds, and > in the meantime there could be a premature close of > the socket before the SSL handshake protocol has > finished. No this is not the case as ive added the cert to my root certs. And it mostly happens when loading the images in the document i'm first loading; i.e. when the requests come close to each other or perhaps in the same HTTP/1.1 connection (but i've tried Connection: close too). > > If there is a premature closure (which is probably not > the case as you see "broken pipe" messages) I would > recommend that you increase the timeout that Simple is > using. To do this make sure the > simple.http.poller=3Dsimple.http.GranularPoller. You can > set this with a -D parameter like so: > > java -Dsimple.http.poller=3Dsimple.http.GranularPoller > > I hope this solves your problem, or at least helps? Nope. > > Niall > > --- Martin Norrsken <mar...@gm...> wrote: > > > While using simpleweb with SSL on a Java5 platform i > > consistently get > > the following client error from time to time: > > > > javax.net.ssl.SSLException: Received fatal alert: > > unexpected_message > > > > and i get a broken pipe exception at the server > > side. > > > > Do you have any special recommendations on how to > > use SimpleWeb in an > > SSL environment? Should i use some kind of OpenSSL > > wrapper instread of > > JSSE? > > > > /Martin > > > > > > > ------------------------------------------------------- > > This SF.Net email is sponsored by: > > Power Architecture Resource Center: Free content, > > downloads, discussions, > > and more. > > http://solutions.newsforge.com/ibmarch.tmpl > > _______________________________________________ > > Simpleweb-Support mailing list > > Sim...@li... > > > https://lists.sourceforge.net/lists/listinfo/simpleweb-support > > > > > Niall Gallagher > > > > __________________________________ > Start your day with Yahoo! - Make it your home page! > http://www.yahoo.com/r/hs > > > ------------------------------------------------------- > This SF.Net email is sponsored by: > Power Architecture Resource Center: Free content, downloads, discussions, > and more. http://solutions.newsforge.com/ibmarch.tmpl > _______________________________________________ > Simpleweb-Support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simpleweb-support > |
From: Niall G. <gal...@ya...> - 2005-10-19 19:50:27
|
Hi Martin, I have used SSL quite frequently in Java 4, and never encountered this problem. Although I can say that the broken pipe you see on the server side indicates that it is the client that is closing the socket. If the client is closing the connection then there is misconfiguration of the SSL socket. SSL is intependant from HTTP, so I can't really say whats happening. However, I can imagine that if you are using a self signed certificate and are prompted to accept from your browser this can take about 5 to 10 seconds, and in the meantime there could be a premature close of the socket before the SSL handshake protocol has finished. If there is a premature closure (which is probably not the case as you see "broken pipe" messages) I would recommend that you increase the timeout that Simple is using. To do this make sure the simple.http.poller=simple.http.GranularPoller. You can set this with a -D parameter like so: java -Dsimple.http.poller=simple.http.GranularPoller I hope this solves your problem, or at least helps? Niall --- Martin Norrsken <mar...@gm...> wrote: > While using simpleweb with SSL on a Java5 platform i > consistently get > the following client error from time to time: > > javax.net.ssl.SSLException: Received fatal alert: > unexpected_message > > and i get a broken pipe exception at the server > side. > > Do you have any special recommendations on how to > use SimpleWeb in an > SSL environment? Should i use some kind of OpenSSL > wrapper instread of > JSSE? > > /Martin > > > ------------------------------------------------------- > This SF.Net email is sponsored by: > Power Architecture Resource Center: Free content, > downloads, discussions, > and more. > http://solutions.newsforge.com/ibmarch.tmpl > _______________________________________________ > Simpleweb-Support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simpleweb-support > Niall Gallagher __________________________________ Start your day with Yahoo! - Make it your home page! http://www.yahoo.com/r/hs |
From: Martin N. <mar...@gm...> - 2005-10-18 10:16:42
|
While using simpleweb with SSL on a Java5 platform i consistently get the following client error from time to time: javax.net.ssl.SSLException: Received fatal alert: unexpected_message and i get a broken pipe exception at the server side. Do you have any special recommendations on how to use SimpleWeb in an SSL environment? Should i use some kind of OpenSSL wrapper instread of JSSE? /Martin |
From: Niall G. <gal...@ya...> - 2005-10-10 15:24:56
|
Hi If you would like to tell the client when something was last modified you would set: Response.setDate("last-modified", date) Setting the Request will have no affect. In short, setDate and getDate in both the Request and Response objects will get and set dates in the HTTP request and response headers respectively. How you use them is up to you... Niall --- Carfield Yim <car...@gm...> wrote: > In fact, I've override HttpServlet.getLastModified() > so that the cache > work better. I guess similar logic in simple is > Request.setDate("last-modified", date), right? > > On 10/10/05, Carfield Yim <car...@gm...> > wrote: > > Request?? Or it should be Response? > > > > On 10/10/05, Niall Gallagher > <gal...@ya...> wrote: > > > Hi > > > > > > Yes, you do the following > > > > > > Request.getDate("last-modified") > > > > > > or if you want to check conditional headers > > > > > > Request.getDate("if-modified-since") > > > > > > Niall > > > > > > --- Carfield Yim <car...@ca...> > wrote: > > > > > > > Anyone know what is the simple api work > similar to > > > > the following API > > > > of HttpServlet? > > > > > > > > protected final long getLastModified(final > > > > HttpServletRequest req) > > > > > > > > > > > > > > > > ------------------------------------------------------- > > > > This SF.Net email is sponsored by: > > > > Power Architecture Resource Center: Free > content, > > > > downloads, discussions, > > > > and more. > > > > http://solutions.newsforge.com/ibmarch.tmpl > > > > > _______________________________________________ > > > > Simpleweb-Support mailing list > > > > Sim...@li... > > > > > > > > https://lists.sourceforge.net/lists/listinfo/simpleweb-support > > > > > > > > > > > > > Niall Gallagher > > > > > > > > > > > > __________________________________ > > > Start your day with Yahoo! - Make it your home > page! > > > http://www.yahoo.com/r/hs > > > > > > > > > > ------------------------------------------------------- > > > This SF.Net email is sponsored by: > > > Power Architecture Resource Center: Free > content, downloads, discussions, > > > and more. > http://solutions.newsforge.com/ibmarch.tmpl > > > _______________________________________________ > > > Simpleweb-Support mailing list > > > Sim...@li... > > > > https://lists.sourceforge.net/lists/listinfo/simpleweb-support > > > > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: > Power Architecture Resource Center: Free content, > downloads, discussions, > and more. > http://solutions.newsforge.com/ibmarch.tmpl > _______________________________________________ > Simpleweb-Support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simpleweb-support > Niall Gallagher __________________________________ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com |
From: Carfield Y. <car...@gm...> - 2005-10-10 14:32:01
|
In fact, I've override HttpServlet.getLastModified() so that the cache work better. I guess similar logic in simple is Request.setDate("last-modified", date), right? On 10/10/05, Carfield Yim <car...@gm...> wrote: > Request?? Or it should be Response? > > On 10/10/05, Niall Gallagher <gal...@ya...> wrote: > > Hi > > > > Yes, you do the following > > > > Request.getDate("last-modified") > > > > or if you want to check conditional headers > > > > Request.getDate("if-modified-since") > > > > Niall > > > > --- Carfield Yim <car...@ca...> wrote: > > > > > Anyone know what is the simple api work similar to > > > the following API > > > of HttpServlet? > > > > > > protected final long getLastModified(final > > > HttpServletRequest req) > > > > > > > > > > > ------------------------------------------------------- > > > This SF.Net email is sponsored by: > > > Power Architecture Resource Center: Free content, > > > downloads, discussions, > > > and more. > > > http://solutions.newsforge.com/ibmarch.tmpl > > > _______________________________________________ > > > Simpleweb-Support mailing list > > > Sim...@li... > > > > > https://lists.sourceforge.net/lists/listinfo/simpleweb-support > > > > > > > > > Niall Gallagher > > > > > > > > __________________________________ > > Start your day with Yahoo! - Make it your home page! > > http://www.yahoo.com/r/hs > > > > > > ------------------------------------------------------- > > This SF.Net email is sponsored by: > > Power Architecture Resource Center: Free content, downloads, discussion= s, > > and more. http://solutions.newsforge.com/ibmarch.tmpl > > _______________________________________________ > > Simpleweb-Support mailing list > > Sim...@li... > > https://lists.sourceforge.net/lists/listinfo/simpleweb-support > > > |
From: Carfield Y. <car...@gm...> - 2005-10-10 14:15:20
|
Request?? Or it should be Response? On 10/10/05, Niall Gallagher <gal...@ya...> wrote: > Hi > > Yes, you do the following > > Request.getDate("last-modified") > > or if you want to check conditional headers > > Request.getDate("if-modified-since") > > Niall > > --- Carfield Yim <car...@ca...> wrote: > > > Anyone know what is the simple api work similar to > > the following API > > of HttpServlet? > > > > protected final long getLastModified(final > > HttpServletRequest req) > > > > > > > ------------------------------------------------------- > > This SF.Net email is sponsored by: > > Power Architecture Resource Center: Free content, > > downloads, discussions, > > and more. > > http://solutions.newsforge.com/ibmarch.tmpl > > _______________________________________________ > > Simpleweb-Support mailing list > > Sim...@li... > > > https://lists.sourceforge.net/lists/listinfo/simpleweb-support > > > > > Niall Gallagher > > > > __________________________________ > Start your day with Yahoo! - Make it your home page! > http://www.yahoo.com/r/hs > > > ------------------------------------------------------- > This SF.Net email is sponsored by: > Power Architecture Resource Center: Free content, downloads, discussions, > and more. http://solutions.newsforge.com/ibmarch.tmpl > _______________________________________________ > Simpleweb-Support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simpleweb-support > |
From: Niall G. <gal...@ya...> - 2005-10-10 13:29:16
|
Hi Yes, you do the following Request.getDate("last-modified") or if you want to check conditional headers Request.getDate("if-modified-since") Niall --- Carfield Yim <car...@ca...> wrote: > Anyone know what is the simple api work similar to > the following API > of HttpServlet? > > protected final long getLastModified(final > HttpServletRequest req) > > > ------------------------------------------------------- > This SF.Net email is sponsored by: > Power Architecture Resource Center: Free content, > downloads, discussions, > and more. > http://solutions.newsforge.com/ibmarch.tmpl > _______________________________________________ > Simpleweb-Support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simpleweb-support > Niall Gallagher __________________________________ Start your day with Yahoo! - Make it your home page! http://www.yahoo.com/r/hs |
From: Carfield Y. <car...@ca...> - 2005-10-10 11:45:16
|
Anyone know what is the simple api work similar to the following API of HttpServlet? protected final long getLastModified(final HttpServletRequest req) |
From: Carfield Y. <car...@gm...> - 2005-10-05 04:20:27
|
Nearly done, thx for support, still have some minor issue > You can create your own Mapper object to return the > name of your ActionService implementation. For > example: > After I do that, at the constructor, it complaint system is null, thus instead of core.Context temp =3D (core.Context)system.get("core= "); if(temp =3D=3D null) { final File file =3D new File("WEB-INF/data/"= ); temp =3D new core.Context(file); system.put("core", temp); } ctx =3D temp; At constructor, now I just use static variable to held core.Context The other problem is context.getMimeType(location.getName()) always return "application/octetstream" for unknown type, which is not very handle for me. Otherwise , all are working :-) |
From: Niall G. <gal...@ya...> - 2005-10-04 21:35:10
|
Hi Carfield, --- Carfield Yim <car...@ca...> wrote: > Nearly done, thx for support, still have some minor > issue > > > You can create your own Mapper object to return > the > > name of your ActionService implementation. For > > example: > > > After I do that, at the constructor, it complaint > system is null, thus > instead of > > core.Context temp = > (core.Context)system.get("core"); > if(temp == null) { > final File file = new > File("WEB-INF/data/"); > temp = new > core.Context(file); > system.put("core", > temp); > } > ctx = temp; > > At constructor, now I just use static variable to > held core.Context Not sure what your problem is here. But if it works then great! > The other problem is > context.getMimeType(location.getName()) always > return "application/octetstream" for unknown type, > which is not very > handle for me. This is a requirement of the HTTP/1.1 specification. Just edit simple/http/serve/Mime.properties to map file extensions to types. Niall Niall Gallagher __________________________________ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com |