comp.lang.java.programmer http://groups-beta.google.com/group/comp.lang.java.programmer [EMAIL PROTECTED]
Today's topics: * String Integer Input check - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b0afe846354ae58d * How do I get a servlet to read web.xml <param*> lines? - 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/52a0ae56a200643c * old Java compiler - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a0a7bed0e02e6a2a * Java 1.5 Enums - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8cd26ba0bb283203 * Serilization - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3ced838188fc9b7b * Xml and java - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9bc49a003c823b8d * Writing to Word documents - 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/63e6214e752428a * Writting data to a SocketChannel using NIO - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/73de6bca3d676791 * Struts Resources - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c6584cf03252cca4 * explanations about the Decorator design pattern - 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cdc793ab3b8e63d7 * Tomcat - DataSource Exception - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7adac2daa2a6844f * Using java.util.regex in JDK 1.3 - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2a4390453d4e5927 * How to exclude a string using regexp pattern? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e2c5860c47dc5d15 * How to create RPM package for Java app? - 4 messages, 3 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/51fb778378e3b88 * How to starthandshake with client browser?? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2d41b9d8f6879f8b * default constructor in Java versus C++ - 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b0018dff5a806578 * Strategy help for java search engine weighting - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/61841a87697ddc1e * jsps and tomcat - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/97a1ba7b22c7b8dd ========================================================================== TOPIC: String Integer Input check http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b0afe846354ae58d ========================================================================== == 1 of 2 == Date: Sun, Nov 14 2004 1:15 pm From: Dave Neary <[EMAIL PROTECTED]> Hi, On Sun, 14 Nov 2004 22:03:55 +0100, Paul Wagener said: > Problem: > User is expected to input a String type. > How to check if the input is valid and not of Integer type? Every string which can be parsed to an integer is a valid String... To check whether you can parse a string as an integer, try to parse it int i; String s = "132"; try { i = Integer.parseInt(s); } catch (NumberFormatException nfe) { System.err.println("s is not parseable as an integer"); } Cheers, Dave. -- David Neary, E-Mail: bolsh at gimp dot org Work e-mail: d dot neary at phenix dot fr CV: http://dneary.free.fr/CV/ == 2 of 2 == Date: Sun, Nov 14 2004 1:21 pm From: "VisionSet" <[EMAIL PROTECTED]> "Paul Wagener" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi folks, > > Problem: > User is expected to input a String type. > How to check if the input is valid and not of Integer type? Integer as text is a subset of String, that aside... You probably don't want to throw exceptions if you expect it to be a String. So do myString.toCharArray(), then step through and check each char with Character.isDigit(myChar[i]) -- Mike W ========================================================================== TOPIC: How do I get a servlet to read web.xml <param*> lines? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/52a0ae56a200643c ========================================================================== == 1 of 3 == Date: Sun, Nov 14 2004 1:48 pm From: [EMAIL PROTECTED] (miguelk) I'm working through some examples about servlet programming and have run into a problem. I can't get the servlet to read configuration parameters. I'm using Tomcat 5.0.28. The web.xml file I have goes like this: [snip] <servlet> <servlet-name>ConfigDemo</servlet-name> <servlet-class>ConfigDemoServlet</servlet-class> </servlet> <init-param> <param-name>adminContact</param-name> <param-value>Miguel</param-value> </init-param> <servlet-mapping> <servlet-name>ConfigDemo</servlet-name> <url-pattern>/servlet/ConfigDemoServlet</url-pattern> </servlet-mapping> [snap] My servlet code to show the parameters goes like this: [snip] public class ConfigDemoServlet extends GenericServlet implements Servlet { public void init(ServletConfig config) throws ServletException { Enumeration parameters = config.getInitParameterNames(); System.out.println("has elements? " + parameters.hasMoreElements()); while (parameters.hasMoreElements()) { String parameter = (String) parameters.nextElement(); System.out.print("parameter " + parameter + " = "); System.out.println(config.getInitParameter(parameter)); } } ....... [snap] But when run, all I get is: has elements? false My directory structure looks like this: \tomcat 5.0\webapps\budi\WEB-INF\classes where web.xml is under WEB-INF. What am I doing wrong? Thanks. Miguel == 2 of 3 == Date: Sun, Nov 14 2004 2:56 pm From: Igor Kolomiyets <[EMAIL PROTECTED]> Miguel, web.xml should be in \tomcat 5.0\webapps\budi\WEB-INF not in \tomcat 5.0\webapps\budi\WEB-INF\classes Best regards, Igor. miguelk wrote: > I'm working through some examples about servlet programming and have > run into a problem. I can't get the servlet to read configuration > parameters. I'm using Tomcat 5.0.28. The web.xml file I have goes like > this: > > [snip] > <servlet> > <servlet-name>ConfigDemo</servlet-name> > <servlet-class>ConfigDemoServlet</servlet-class> > </servlet> > <init-param> > <param-name>adminContact</param-name> > <param-value>Miguel</param-value> > </init-param> > <servlet-mapping> > <servlet-name>ConfigDemo</servlet-name> > <url-pattern>/servlet/ConfigDemoServlet</url-pattern> > </servlet-mapping> > [snap] > > My servlet code to show the parameters goes like this: > > [snip] > public class ConfigDemoServlet extends GenericServlet implements > Servlet { > public void init(ServletConfig config) throws ServletException { > Enumeration parameters = config.getInitParameterNames(); > System.out.println("has elements? " + > parameters.hasMoreElements()); > while (parameters.hasMoreElements()) { > String parameter = (String) parameters.nextElement(); > System.out.print("parameter " + parameter + " = "); > System.out.println(config.getInitParameter(parameter)); > } > } > ....... > [snap] > > But when run, all I get is: > > has elements? false > > My directory structure looks like this: > > \tomcat 5.0\webapps\budi\WEB-INF\classes where web.xml is under > WEB-INF. > > What am I doing wrong? > > Thanks. > > Miguel == 3 of 3 == Date: Sun, Nov 14 2004 2:40 pm From: Oscar kind <[EMAIL PROTECTED]> miguelk <[EMAIL PROTECTED]> wrote: > I'm working through some examples about servlet programming and have > run into a problem. I can't get the servlet to read configuration > parameters. I'm using Tomcat 5.0.28. The web.xml file I have goes like > this: > > [snip] > <servlet> > <servlet-name>ConfigDemo</servlet-name> > <servlet-class>ConfigDemoServlet</servlet-class> > </servlet> > <init-param> > <param-name>adminContact</param-name> > <param-value>Miguel</param-value> > </init-param> > <servlet-mapping> > <servlet-name>ConfigDemo</servlet-name> > <url-pattern>/servlet/ConfigDemoServlet</url-pattern> > </servlet-mapping> > [snap] > > My servlet code to show the parameters goes like this: > > [snip] > public class ConfigDemoServlet extends GenericServlet implements > Servlet { > public void init(ServletConfig config) throws ServletException { > Enumeration parameters = config.getInitParameterNames(); > System.out.println("has elements? " + > parameters.hasMoreElements()); > while (parameters.hasMoreElements()) { > String parameter = (String) parameters.nextElement(); > System.out.print("parameter " + parameter + " = "); > System.out.println(config.getInitParameter(parameter)); > } > } > ....... > [snap] > > But when run, all I get is: > > has elements? false [...] > What am I doing wrong? The servlet prameters are not in the servlet tag, and thus do not belong to the sertvlet. More the init-param tags within the servlet tag, and see what happens. -- Oscar Kind http://home.hccnet.nl/okind/ Software Developer for contact information, see website PGP Key fingerprint: 91F3 6C72 F465 5E98 C246 61D9 2C32 8E24 097B B4E2 ========================================================================== TOPIC: old Java compiler http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a0a7bed0e02e6a2a ========================================================================== == 1 of 2 == Date: Sun, Nov 14 2004 1:48 pm From: "Sam" <[EMAIL PROTECTED]> Hello, I'm working on an applet that should run with Microsoft's JVM. I read that I need Java Version 1.1.4 for that. Where can I download that vesrion? I couldn't find anything on the Sun pages. Thanks! Sam == 2 of 2 == Date: Sun, Nov 14 2004 7:46 pm From: Andrew Thompson <[EMAIL PROTECTED]> On Sun, 14 Nov 2004 21:48:22 GMT, Sam wrote: > I'm working on an applet that should run with Microsoft's JVM. I read that I > need Java Version 1.1.4 for that. > Where can I download that vesrion? I couldn't find anything on the Sun > pages. MS withdrew all support for the MSVM and Sun never supplied it. If you have an IE that has the MSVM built in, you're in luck though. -- Andrew Thompson http://www.PhySci.org/codes/ Web & IT Help http://www.PhySci.org/ Open-source software suite http://www.1point1C.org/ Science & Technology http://www.LensEscapes.com/ Images that escape the mundane ========================================================================== TOPIC: Java 1.5 Enums http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8cd26ba0bb283203 ========================================================================== == 1 of 1 == Date: Sun, Nov 14 2004 2:29 pm From: Chas Douglass <[EMAIL PROTECTED]> "Tony Morris" <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > "Chas Douglass" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> I'm interested in using the new Java 1.5 Enum type, but I'm wondering >> if it's the best way to represent certain values retrofitting into a >> current application. [snip] >> So is there a reasonable way to implement this, or should I stick >> with "static final int" constants. >> >> Thanks. >> >> Chas Douglass > > You want to create an enum and a reverse mapping. > Suppose you have 2 ints {0,1} that mean something {BLACK, WHITE}. [snip] Thanks, that solution was totally non-obvious to me, but it works perfectly. Chas Douglass ========================================================================== TOPIC: Serilization http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3ced838188fc9b7b ========================================================================== == 1 of 1 == Date: Sun, Nov 14 2004 2:09 pm From: Oscar kind <[EMAIL PROTECTED]> Ken Adams <[EMAIL PROTECTED]> wrote: > What is an easy way to check if a file has any serialization data in it. > Basically plan an using a file named data.dat to hold my backup of my prog. > But I want to be able to upon running the prog be able to check the file and > if their is a serilized object in the file then initilize my objects in my > prog else I want to just create new blank objects in my prog. Any > suggestions. If the file exists, try restoring the backup. It that throws an exception: log the exception, remove the file and continue like nothing happened. The file didn't containa backup. -- Oscar Kind http://home.hccnet.nl/okind/ Software Developer for contact information, see website PGP Key fingerprint: 91F3 6C72 F465 5E98 C246 61D9 2C32 8E24 097B B4E2 ========================================================================== TOPIC: Xml and java http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9bc49a003c823b8d ========================================================================== == 1 of 1 == Date: Sun, Nov 14 2004 3:12 pm From: "tgn" <[EMAIL PROTECTED]> Hi there, i need for some snippet of java codes, that from a xml file like this: <People> <Employ> John Denver </Employ> ...A subtree.... <Employ> Mike Harris> </Employ> ....Another subtree.... <Employ> Mark White </Employ> .....More subtree.... </People> Extract an employ of given key (i.e. John Denver) with its subtree in a string. Is this a simple thing? Thanks for the attention, Awy ========================================================================== TOPIC: Writing to Word documents http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/63e6214e752428a ========================================================================== == 1 of 3 == Date: Sun, Nov 14 2004 3:14 pm From: [EMAIL PROTECTED] (Jonck van der Kogel) Hi everybody, I have defined a Word template and set bookmarks at certain locations in this document, to which I then want to write text gotten from a database and save the file. In this way I could create standard documents (for example an invoice) in an automated manner. I have looked into the Jakarta POI project (http://jakarta.apache.org/poi/index.html), but this project is mostly aimed at Excel, Word support is still in its infancy. Another solution that I've found (http://www.must.de/en/default.html?../Javactpe.htm) seems to work very well, but is Windows only. Also there are a few commercial solutions, but these cost several thousand dollars, which I can't afford. I figure such an automated creation of Word documents is probably being done by a lot of people, so therefore I was wondering, does anyone know of a (affordable) way to achieve what I described in a platform independent manner? Thanks very much, Jonck == 2 of 3 == Date: Sun, Nov 14 2004 3:37 pm From: Sudsy <[EMAIL PROTECTED]> Jonck van der Kogel wrote: <snip> > I figure such an automated creation of Word documents is probably > being done by a lot of people, so therefore I was wondering, does > anyone know of a (affordable) way to achieve what I described in a > platform independent manner? As I've tried to explain to many potential employers, you're not likely to find people equally adept at both .NET and Java. Similarly, NT Server and Linux administration experience tends to be mutually exclusive; if you're truly expert at one then you're not likely to be as proficient in the other. Very different mind- sets, although exceptions do exist. To address your specific issue, Microsoft® controls the format of documents created/used by their products. They don't make the inside information available unless you're a major customer (read: BIG$) and sign an onerous NDA. So don't expect someone who has made the huge investment in time and effort to decode the formats to provide the fruits of their labour without charge. There ARE alternatives to proprietary formats, BTW. Those of us seeking portability will typically choose one of those rather than be tethered to a capricious vendor. As always, YMMV. -- Java/J2EE/JSP/Struts/Tiles/C/UNIX consulting and remote development. == 3 of 3 == Date: Sun, Nov 14 2004 7:44 pm From: Andrew Thompson <[EMAIL PROTECTED]> On 14 Nov 2004 15:14:53 -0800, Jonck van der Kogel wrote: (based on the assumption you've already read Sudsy's comments) > I have defined a Word template and set bookmarks at certain locations > in this document, to which I then want to write text gotten from a > database and save the file. In this way I could create standard > documents (for example an invoice) in an automated manner. Use HTML for your invoices. It makes a lot more sense. -- Andrew Thompson http://www.PhySci.org/codes/ Web & IT Help http://www.PhySci.org/ Open-source software suite http://www.1point1C.org/ Science & Technology http://www.LensEscapes.com/ Images that escape the mundane ========================================================================== TOPIC: Writting data to a SocketChannel using NIO http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/73de6bca3d676791 ========================================================================== == 1 of 1 == Date: Sun, Nov 14 2004 3:28 pm From: Esmond Pitt <[EMAIL PROTECTED]> Fritz Bayer wrote: > What do you think about testing > isWriteable() in the SelectionKey at that point? Absolutely. > Of course the state is lilkely to be obsolete unless the channels was > not writeable at the time, when last selection via select() took > place. The state held in a SelectionKey resulting from a select() is in principle *always* obsolete. This doesn't matter in practice unless you have other threads playing with the same socket channels, as incoming data or connections or outgoing buffer space won't just go away. In other words isAcceptable(), isReadable(), isConnectable(), is Writable() are always obsolete but always reliable. (However of course their *negations* are obsolete but *not* reliable, as e.g. !isWritable() can change very quickly, you only have to drain one byte to the network.) ========================================================================== TOPIC: Struts Resources http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c6584cf03252cca4 ========================================================================== == 1 of 1 == Date: Sun, Nov 14 2004 3:37 pm From: [EMAIL PROTECTED] (Jeremy) Hello, I am developing an application using STRUTS and have an interesting problem. The resources concept is good, and ties in with the STRUTS framework nicely, however, my company requires the values in this resource file to originate, and be maintainable, from a mainframe. I have done a bit of browsing, and the closest I have gotten so far is that in the Action I access the MessageResources and, maybe, the MessageResourcesFactory. However, these classes only provide basic read-only type access. I do not want to be too "tricky" in an implementation, as the code should be reasonably generic and not require re-analysing when/if we upgrade to a new version/implementation of STRUTS. Has anyone had the same problem, and hopefully, got an answer? Thanks in advance, Jeremy ========================================================================== TOPIC: explanations about the Decorator design pattern http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cdc793ab3b8e63d7 ========================================================================== == 1 of 3 == Date: Sun, Nov 14 2004 3:45 pm From: [EMAIL PROTECTED] (Jean Lutrin) Hi all, I have two questions: one regarding a pattern that I don't know the name of and one other regarding the decorator pattern. In one project I've been working on, I had to optimize a *very* memory consuming code (which I didn't write). The code (oversimplified) looks like this : abstract class SomeClass { abstract int doSomeTask(); abstract int doAnotherTask(); abstract int doAThirdTask(); } class Inefficient extends SomeClass { int doSomeTask() { // very ineficient method consuming lots of ressources } int doAnotherTask() { ... } int doAThirdTask() { ... } } Once we noticed there were problems in the code, we ran a profiler and noticed an excessive memory usage traced back to one single method. We had no access to the source code, so I did the following. I added an "optimized method" class looking like this : class Efficient extends SomeClass { private Inefficient wrapped; Efficient() { wrapped = new Inefficient(); } int doSomeTask() { // optimized method }; int doSomeOtherTask() { return wrapped.doSomeOtherTask(); } int doAThirdTask() { return wrapped.doSomeOtherTask(); } } Note that I extend SomeClass and not the Inefficient class. This way, the client of this class only see that the class they use extends SomeClass : they don't need to know that Efficient actually "wrap" an Inefficient object. The inefficient method of the Inefficient class is never called : it has been "replaced" by another method, much more optimized. For all the rest, it is the old class that actually does all the job. Everything is working all and well (and "non-garbage-collectable" memory usage went way down btw, by a factor of 60 !, which was actually the whole purpose of this manipulation). However, I don't know if there's a name for this way of proceeding. I don't add any new functionality to the class: it is a concrete implementation of the abstract class. And this implementation is based, under the hood, on another concrete implementation of the abstract class (but nobody notices it: this detail is hidden from the client). Nothing is added, no new functionality is added. How would you name this way of proceeding ? Is it similar to some well known pattern ? My second question concerns the Decorator pattern. The Java I/O streams are often cited, nearly everywhere, as *the* major use of the Decorator pattern in the Java API Let's look at those three : public abstract class InputStream {...} public class FilterInputStream extends InputStream {...} public class BufferedInputStream extends FilterInputStream {...} Which class is said to be decorating which one ? In a post from the year 2000, on this very group, I found the following : > A classic example in Java is the FilterInputStream > class (and its many subclasses BufferedInputStream, > DataInputStream, CheckedInputStream, InflaterInputStream, > DigestInputStream, LineNumberInputStream, PushbackInputStream) > which is a Decorator of an InputStream. It provides the same > API as the InputStream which it wraps, but allows you to > add additional capability. It is this idea of adding > functionality by wrapping another object while implementing > the same API that is characteristic of the Decorator pattern. > > I too, think Decorator is an extremely poor name. I would be tempted to say "of course that the FilterInputStream has the same interface as the InputStream"... The InputStream is an abstract class ! So Does it means that everytime you extends an abstract class (without making the extending class final) you are using the "Decorator" pattern ? I don't see which object is wrapping which one : do you really find that the FilterInputStream wraps the abstract InputStream class ? Thanks in advance for any help on this. As always, excuse my french ;) Jean == 2 of 3 == Date: Sun, Nov 14 2004 5:53 pm From: "xarax" <[EMAIL PROTECTED]> "Jean Lutrin" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi all, > > I have two questions: one regarding a pattern > that I don't know the name of and one other > regarding the decorator pattern. > > In one project I've been working on, I had to optimize > a *very* memory consuming code (which I didn't write). > > The code (oversimplified) looks like this : > > abstract class SomeClass { > abstract int doSomeTask(); > abstract int doAnotherTask(); > abstract int doAThirdTask(); > } > > class Inefficient extends SomeClass { > int doSomeTask() { > // very ineficient method consuming lots of ressources > } > > int doAnotherTask() { > ... > } > > int doAThirdTask() { > ... > } > } > > Once we noticed there were problems in the code, we > ran a profiler and noticed an excessive memory usage > traced back to one single method. > > We had no access to the source code, so I did the > following. > > I added an "optimized method" class looking like this : > > class Efficient extends SomeClass { > private Inefficient wrapped; > > Efficient() { > wrapped = new Inefficient(); > } > > int doSomeTask() { > // optimized method > }; > > int doSomeOtherTask() { > return wrapped.doSomeOtherTask(); > } > > int doAThirdTask() { > return wrapped.doSomeOtherTask(); > } > } > > Note that I extend SomeClass and not the Inefficient class. This > way, the client of this class only see that the class they use > extends SomeClass : they don't need to know that Efficient > actually "wrap" an Inefficient object. The inefficient method > of the Inefficient class is never called : it has been "replaced" by > another method, much more optimized. For all the rest, it is > the old class that actually does all the job. /snip/ What's wrong with just extending Inefficient and overriding doSomeTask() ? == 3 of 3 == Date: Sun, Nov 14 2004 6:17 pm From: "Tony Morris" <[EMAIL PROTECTED]> "Jean Lutrin" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi all, > > I have two questions: one regarding a pattern > that I don't know the name of and one other > regarding the decorator pattern. > > In one project I've been working on, I had to optimize > a *very* memory consuming code (which I didn't write). > > The code (oversimplified) looks like this : > > abstract class SomeClass { > abstract int doSomeTask(); > abstract int doAnotherTask(); > abstract int doAThirdTask(); > } > > class Inefficient extends SomeClass { > int doSomeTask() { > // very ineficient method consuming lots of ressources > } > > int doAnotherTask() { > ... > } > > int doAThirdTask() { > ... > } > } > > Once we noticed there were problems in the code, we > ran a profiler and noticed an excessive memory usage > traced back to one single method. What you have there is the Proxy Design Pattern. I'd be inclined to call it the Adapter Design Pattern, but the two share the same API. I have sincere doubts that this is the cause of a performance bottleneck. The Decorator Design Pattern is similar to a Proxy, however, there is one distinguishing feature. The type (typically an interface) being subtyped (always a class) has a member of the type being subtyped. For example a class called XDecorator which decorated the type interface X looks like this: class XDecorator implements X { private X x; ... // all of X methods } The methods that you provide 'decorate' the behaviour of the instance of X that the member field refers to. Typically, this instance is passed in on the constructor. The UML for a Decorator includes two types, the decorating type and the decorated type. There is an inheritance relationship as the decorating type being a subtype of the decorated type. There is also an aggregation relationship from the decorating type to the decorated type. In the case of core I/O, the two abstract classes java.io.InputStream and java.io.OutputStream are the decorated type. The many (not all) concrete implementations are decorating types. Consider java.io.ObjectInputStream. It inherits from java.io.InputStream and you also pass a java.io.InputStream in at construction time. ObjectInputStream 'decorates' the InputStream that you provide it with. AOP solves a lot of the same problems, but in a different way, that a decorator solves. </essay> -- Tony Morris http://xdweb.net/~dibblego/ ========================================================================== TOPIC: Tomcat - DataSource Exception http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7adac2daa2a6844f ========================================================================== == 1 of 1 == Date: Sun, Nov 14 2004 3:53 pm From: "MikL" <[EMAIL PROTECTED]> "Martin Huber" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hello, > > i have a problem. I am using Tomcat 4.0 and MySql as database. I want > using the database connection pooling mechanism in Tomcat, but I have > problems. > > If I test the connection, I get following error message: > > TyrexDataSourceFactory: Cannot create DataSource, Exception > java.lang.NoClassDefFoundError: tyrex/jdbc/xa/EnabledDataSource > at org.apache.naming.factory.TyrexDataSourceFactory.getObjectInstance(Ty > rexDataSourceFactory.java:163) > at org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory. java:165) > at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:301) > . > . > . > A problem occurred while retrieving a DataSource object > javax.naming.NamingException: Exception creating DataSource: > tyrex/jdbc/xa/EnabledDataSource Martin, An approach I have found useful is to first try to get a connection without JNDI using the lower-level DriverManager.getConnection(url,user,password) method. This will prove whether your driver classes are on CLASSPATH, and that the database is accessible. NB. Do this within a TRY-CATCH that catches and reports all _Throwables_ -- one trick I found here is that some driver errors are not Exception subclasses -- they're Errors. HTH, MikL ========================================================================== TOPIC: Using java.util.regex in JDK 1.3 http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2a4390453d4e5927 ========================================================================== == 1 of 1 == Date: Sun, Nov 14 2004 4:46 pm From: "Chris" <[EMAIL PROTECTED]> We've written an app that depends on the regex capability in JDK 1.4, and now the app has to run under 1.3. Rather that do a rewrite to use another regex package, I extracted the java.util.regex.* classes from 1.4 and put them in their own .jar. If I put that .jar on the classpath, then everything compiles fine under 1.3. When I try to run the app, though, I get this error message: java.lang.SecurityException: Prohibited package name: java.util.regex I suppose I could change the package names in the regex source code and recompile, but I'd rather not, because then I'd have to distribute this new jar file, even when deploying under 1.4 or 1.5. Any thoughts on how to solve this problem? ========================================================================== TOPIC: How to exclude a string using regexp pattern? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e2c5860c47dc5d15 ========================================================================== == 1 of 1 == Date: Sun, Nov 14 2004 5:31 pm From: [EMAIL PROTECTED] (Victor) Thanks all your valuable messages!!! I have just tried Alan's solution and it works!! Though there are "nnn" at the end, I have updated the solution to output the exact string I want: <regexp pattern="(?:[^\[]+|\[(?!GC ))*+((?:\[GC [^\]]+\])|$)" /> <substitution expression="\1" /> </replaceregexp > Further issue on Unix, if you could share with me (I post this on the unix shell group just now) -- I think it is pretty hard to get the exact output from the Unix grepping tool, as those tool only normally output the WHOLE line of the matched string and I think in this case it is difficult to get to more granularity of the match, ie. the exact output of the match: So, do you know how to output the exact match after the pattern search, rather than the whole matched line? For example if I have this log.txt: lots of irrelevant strings lots of irrelevant strings [Mon Nov 15 11:46:01 EST 2004] stdout: [GC 21044K->13925K(65600K), 0.0065250 se cs] lots of irrelevant strings lots of irrelevant strings And if I use the egrep: egrep "\[GC.*\]" log.txt, I can only get this: [Mon Nov 15 11:46:01 EST 2004] stdout: [GC 21044K->13925K(65600K), 0.0065250 se cs] But if I only want to see this (only part of the line in the file): [GC 21044K->13925K(65600K), 0.0065250 secs] And event more greedy, to tidy the output as this: 21044, 13925, 65600 Anyone have any idea of doing this? Again, thanks very much for your efficient help!!! Victor Alan Moore <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > On 11 Nov 2004 22:23:03 -0800, [EMAIL PROTECTED] (Victor) wrote: > > > From the following log.txt file, if I want to remove the other strings > > but to keep the "[GC 84000K->74959K(88984K), 0.0250350 secs]" string: > > > > [Thu Nov 11 00:34:25 EST 2004] stderr: ejbcontainer: >>>> EJB LOG > > >>>> > > [Fri Nov 12 01:15:19 EST 2004] stdout: [GC 84000K->74959K(88984K), > > 0.0250350 secs] > > > > What regexp pattern I should use? For example, if I specify a "!" in > > front of the pattern (\[GC.*\]) which is correctly representing the > > "[GC 84000K->74959K(88984K), 0.0250350 secs]" string: > > > > <replaceregexp file= "C:\log.txt" flags= "s" > > > <regexp pattern="!(\[GC.*\])" /> > > <substitution expression="" /> > > </replaceregexp > > > > > It just won't work. > > > > Do you have any idea(obviously we can't use the '^' for this purpose)? > > Or I have to create a new java program to do this? > > Unfortunately, regexes don't provide a way to not-match specific > sequences of characters, but through creative use of lookaround and > negated character classes, we can usually manage it. Try this: > > <replaceregexp file= "C:\log.txt" flags= "g" > > <regexp pattern="(?:[^\[]++|\[(?!GC ))*+((?:\[GC [^\]]++\])|$)" /> > <substitution expression="\1\n" /> > </replaceregexp > > > That is, match one or more of any character other than an open > bracket, or an open bracket if it's not followed by "GC ", repeated > zero or more times. That part of the regex will match everything up > to the next GC block (or to the end of the file if there aren't any > more GC blocks), and the text matched by it will be discarded. Upon > finding an open bracket that's followed by "GC ", the next part will > match and capture everything up to and including the next close > bracket, and that text will be inserted into the output. > > With this regex, you don't need to use the "s" flag, but you may need > to use the "g" flag--I'm not sure if Ant requires that when you're > using the JDK regex engine (I assume that's what you're using; if not, > this regex won't work at all). ========================================================================== TOPIC: How to create RPM package for Java app? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/51fb778378e3b88 ========================================================================== == 1 of 4 == Date: Sun, Nov 14 2004 5:59 pm From: Ahmed Moustafa <[EMAIL PROTECTED]> Hi All, What are the steps to create a RPM package for a Java application for Linux distributions? Your help will be appreciated so much! Ahmed == 2 of 4 == Date: Sun, Nov 14 2004 6:48 pm From: "Chris" <[EMAIL PROTECTED]> > What are the steps to create a RPM package for a Java application for > Linux distributions? There are installers that will do it. The one I use is http://install4j.com, but there are plenty of others that will do the trick. == 3 of 4 == Date: Sun, Nov 14 2004 6:54 pm From: Ahmed Moustafa <[EMAIL PROTECTED]> Chris wrote: >>What are the steps to create a RPM package for a Java application for >>Linux distributions? > > > There are installers that will do it. The one I use is http://install4j.com, > but there are plenty of others that will do the trick. install4j is not free. == 4 of 4 == Date: Sun, Nov 14 2004 8:04 pm From: Steve Sobol <[EMAIL PROTECTED]> Chris wrote: >>What are the steps to create a RPM package for a Java application for >>Linux distributions? > > > There are installers that will do it. The one I use is http://install4j.com, > but there are plenty of others that will do the trick. Install4J rocks. You can also create an RPM by hand the same way you'd create any other RPM. See http://www.rpm.org/ for more details and docs. -- JustThe.net Internet & New Media Services, http://JustThe.net/ Steven J. Sobol, Geek In Charge / 888.480.4NET (4638) / [EMAIL PROTECTED] PGP Key available from your friendly local key server (0xE3AE35ED) Apple Valley, California Nothing scares me anymore. I have three kids. ========================================================================== TOPIC: How to starthandshake with client browser?? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2d41b9d8f6879f8b ========================================================================== == 1 of 1 == Date: Sun, Nov 14 2004 6:23 pm From: [EMAIL PROTECTED] (Jakekeke) Thank Rogan again (forget to do so) I have already finished by proxy on SSL part. However my supervisor asked me to implement that part by another way. ie, what i have done is same as your project before every requests will open a new request and response socket now, what my supervisor wants is some request maybe do on same sockets pair ie, maybe there have request ABC after i send back the GET/POST response to request A the thread in the while loop will send me the request B it is no need to open another thread to make CONNECT again I have 2 source right now, however, i dont know the 2nd method works or not, become it sometime does is this the correct way to handle the SSL request?? ========================================================================== TOPIC: default constructor in Java versus C++ http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b0018dff5a806578 ========================================================================== == 1 of 3 == Date: Sun, Nov 14 2004 7:11 pm From: [EMAIL PROTECTED] (Matt) I try to compare the default constructor in Java and C++. In C++, a default constructor has one of the two meansings 1) a constructor has ZERO parameter Student() { //etc... } 2) a constructor that all parameters have default values Student(int age = 10, String name = "Joe") { //etc... } However, In Java, default constructor means a constructor has ZERO parameter only. Student() { //etc... } The following will yield compile errors Student(int age = 10, String name = "Joe") { //etc... } Any ideas why Java doesn't support that? Please advise. Thanks!! == 2 of 3 == Date: Sun, Nov 14 2004 7:16 pm From: "Tony Morris" <[EMAIL PROTECTED]> > Any ideas why Java doesn't support that? This might help. http://www.google.com/search?hl=en&lr=&q=java+default+constructor+parameter+initialization+C%2B%2B -- Tony Morris http://xdweb.net/~dibblego/ == 3 of 3 == Date: Sun, Nov 14 2004 7:58 pm From: "Ann" <[EMAIL PROTECTED]> "Matt" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I try to compare the default constructor in Java and C++. > > In C++, a default constructor has one of the two meansings > 1) a constructor has ZERO parameter > > Student() > { //etc... > } > > 2) a constructor that all parameters have default values > > Student(int age = 10, String name = "Joe") > { //etc... > } > > However, In Java, default constructor means a constructor has ZERO parameter only. > > Student() > { //etc... > } > > The following will yield compile errors > Student(int age = 10, String name = "Joe") > { //etc... > } > > Any ideas why Java doesn't support that? > > Please advise. Thanks!! Same reason algol60 doesn't support it. Maybe you can tell us why C++ doesn't support all the algol60 features. ========================================================================== TOPIC: Strategy help for java search engine weighting http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/61841a87697ddc1e ========================================================================== == 1 of 1 == Date: Sun, Nov 14 2004 7:35 pm From: "Tom Dyess" <[EMAIL PROTECTED]> I'm converting a search engine from Delphi to Java and would like some help with my strategy. This is for the oraclepower.com website. BACKGROUND: I have a table of links that I need to match up with keywords the user enters. If the user enters the keywords "oracle" and "reports" I query the database for all link titles and descriptions that exist in the table something like this SELECT col1..coln FROM LINK_LIST WHERE title like '%keyword%' or subject like '%keyword%' I then pull the recordset into what is called a client data set (Delphi), which is a recordset "in memory" instead of one directly attached to a database or XML file. I then use an algorithm to weight each result based on where and how many times it appears in title and link, then sort by weight, then display the resource to the web page. QUESTION: Do the java libraries have an object that can easily be loaded from a ResultSet, have a weight column added to it then sort itself, then examine the columns from the memory object; or do I have to create this object myself? If I have to create this myself, what objects will help me reduce the coding / designing (ie other than ArrayList or some generic collection). Should this be done with SAX and an in-memory XML object (no file needed, and would slow things down)? Should I create a collection that loads itself from a ResultSet including metadata and can sort by a particular column, set of columns? I know how I would do it in Delphi, but need some insight into various java solutions. Thanks, Tom Dyess OraclePower.com ========================================================================== TOPIC: jsps and tomcat http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/97a1ba7b22c7b8dd ========================================================================== == 1 of 1 == Date: Sun, Nov 14 2004 7:49 pm From: "Ryan" <[EMAIL PROTECTED]> I have a jsp that is running. it converts to a servlet and compiles when i run call the screen with my IE browser. I opened the servlet that was generated and placed in the 'work' directory. i cannot compile the servlet. why? It was just compiled by tomcat. I was able to compile it a little while ago. I would like to be able to test compile the generated servlet, since it tells me more information when i have bugs. do i need to place certain things in my classpath to compile the servlet with 'javac'? ======================================================================= You received this message because you are subscribed to the Google Groups "comp.lang.java.programmer". comp.lang.java.programmer [EMAIL PROTECTED] Change your subscription type & other preferences: * click http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe Report abuse: * send email explaining the problem to [EMAIL PROTECTED] Unsubscribe: * click http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe ======================================================================= Google Groups: http://groups-beta.google.com
