comp.lang.java.programmer http://groups-beta.google.com/group/comp.lang.java.programmer [EMAIL PROTECTED]
Today's topics: * Compiler trick - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a2992422eec9fe49 * store whole InputStream in a String - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d510835287103e9 * byte representation of a class - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/754ced8b07b9a2d3 * Can I get TCPMon free without a bunch of other included software? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b8b8e67ddb9bcd5e * Easy-to-understand Servlet container? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5a6c2be39085acf6 * image.getScaledInstance() bug? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7a7b5c91813f3766 * Java Decompiler and comments - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b2492f14a4a9460f * Successor to Java? - 4 messages, 4 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9151fedffecef56b * open jndi connection to unknown bean - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f470253276355f5e * JSP: How to allow servlet and applet to share jar files? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8913f11160bcd2c1 * obj,fn,parms encapsulation in java - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/620957f075803b3 * EJB: ONE query for multiple rows - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/38eb46fdf71c702c * RMI client behind a firewall, server behind a firewall too - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/898ce13af69b8972 * Java applet failed when I try to load the avi file in my java applet - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/eee0d2c54a4b7feb * JMF need to in all the clients side? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1180e8f61a13d55c * How to use JTree with very large data? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/145516a872afaa18 * MIDlet Database - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/22c02d60b8400694 * Who is the best WebSphere Studio or Oracle JDeveloper?? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/747e9a4c137251d2 * Tomcat + java.io.FileNotFoundException - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7ba2cca95c5415a5 ========================================================================== TOPIC: Compiler trick http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a2992422eec9fe49 ========================================================================== == 1 of 1 == Date: Mon, Sep 13 2004 1:19 pm From: Joona I Palaste <[EMAIL PROTECTED]> dar7yl <[EMAIL PROTECTED]> scribbled the following: > "Chris Uppal" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> Otherwise it becomes hard to understand why the compiler doesn't deduce >> the >> legallity of constructions like: >> >> Objet o = ...; >> if (o instanceof Dog) { o.bark(); } >> > The corrected code is: > <code> > Object o = ...; > if (o instanceof Dog) > { > ( (Dog) o ).bark(); > } > </code> > The rational is that the base Object o does not contain the method 'bark', > so you have to cast it into the required class 'Dog'. > Also, note that the cast of 'o' into 'Dog' is valid at this point, because > it is protected by the 'instanceof' condition enclosing it's use. If you > didn't have the if statement, and tried to cast any object, chances it would > fail with a conversion error exception, assuming a random object 'o'. Your explanation is correct, however I think that Chris already knew that. -- /-- Joona Palaste ([EMAIL PROTECTED]) ------------- Finland --------\ \-- http://www.helsinki.fi/~palaste --------------------- rules! --------/ "Show me a good mouser and I'll show you a cat with bad breath." - Garfield ========================================================================== TOPIC: store whole InputStream in a String http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d510835287103e9 ========================================================================== == 1 of 1 == Date: Mon, Sep 13 2004 1:48 pm From: "ak" <[EMAIL PROTECTED]> >I suppose you think the program > shouldn't be configurable at all in case you break it? no, I just think it should be possible to configure it back to working state without actions like "delete user directory" > The fact that you readily try to blame Paul for messing up the program menus > that *you* reconfigured badly speaks volumes. no, I try to blame Paul for his art to communicate. I posted worked easy understandable code and he was really hard to me. So I just try to show that he is not perfect man. May be I make it wrong way... Back to his editor - tell me why if I put file list at top of menu and then click on "clear file list" then is File menu completely cleared? Is it not a bug? > If you use, and try to configure, a free program, then you do so at your own > risk. ANY programm is used at own risk Please read license agreement. > No satisfaction is guaranteed at all. If you think something is wrong > with it, you could try telling the author - politely - or you could just stop > using the program. > That's it, but the same can be made with commercial programm too. > So tell me, who are the writers of free software thinking of, if not their users? they may just like to write programms. > I would argue that people selling commerical software are primarily thinking of > themselves - i.e. their profits - and are *less* likely to think of the end user. Don't be naive.. They MUST think about users, no users - no profit... Unsatisfacted user means less profit in the future. -- Andrei Kouznetsov http://uio.dev.java.net Unified I/O for Java http://reader.imagero.com Java image reader ========================================================================== TOPIC: byte representation of a class http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/754ced8b07b9a2d3 ========================================================================== == 1 of 1 == Date: Mon, Sep 13 2004 1:56 pm From: Lothar Kimmeringer <[EMAIL PROTECTED]> On 13 Sep 2004 12:14:15 -0700, Benjamin von Eicken wrote: > How can I get a byte representation of > a java class? Read the class-file with a FileInputStream into a byte-array > I do not want to use the class file. What else do you want to use? There is nothing else than the class-file. Alternatively you might use the class-loader, but there you can look into the API (which I would have to do anyway because I don't know how for myself at the moment) > Is it possible to get access to the > byte code? See above. > ObjectOutputStream does it somehow, > but I do not want to use serializable > objects only ObjectOutputStream doesn't write the byte-code of the java-class, only the status of an instance of the specific class. The deserialization gets the information what kind of class to be initialized before setting the values coming from the stream. > and I do not want a > stream. Streams are the basic concept in Java for reading and writing data, so your IMHO going into a wrong direction. > So I want to store an instance of an > object but not in a stream and not > necessary serializable. Get the values by Reflection and print them onto a printer. > Is it possible? See above. > And if, how? Use google for getting more information about Reflection in Java and printing. The latter has different ways for solving, depending on the version of Java to be used. Regards, Lothar -- Lothar Kimmeringer E-Mail: [EMAIL PROTECTED] PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81) Always remember: The answer is forty-two, there can only be wrong questions! ========================================================================== TOPIC: Can I get TCPMon free without a bunch of other included software? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b8b8e67ddb9bcd5e ========================================================================== == 1 of 1 == Date: Mon, Sep 13 2004 2:29 pm From: Bryce <[EMAIL PROTECTED]> On 13 Sep 2004 13:06:25 -0700, [EMAIL PROTECTED] wrote: >Hey all, I used to have IBM Web services installed and it came with a >useful application called TCPMon. > >I did some googl'ing and is seems that an organization called Axis is >the one responsible for the application. FYI, Axis is not an organization, rather its a project. http://ws.apache.org/axis >I was wondering if it would be possible to download the application >(with the GUI) free of charge without getting all the other web >services stuff. If so, can someone direct me to the URL? >Thanks, >Novice Well.. Its packaged in the axis.jar file. Its not like its a whole lot to download. Plus, distributing it seperately might violate their license... -- now with more cowbell ========================================================================== TOPIC: Easy-to-understand Servlet container? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5a6c2be39085acf6 ========================================================================== == 1 of 1 == Date: Mon, Sep 13 2004 2:33 pm From: Bryce <[EMAIL PROTECTED]> Have you checked out Jetty? http://www.mortbay.org/jetty/index.html I usually use Tomcat, but I use Jetty all the time for unit testing. It seems to be fairly well documented. On 13 Sep 2004 12:56:10 -0700, [EMAIL PROTECTED] (Jeff Robertson) wrote: >Does anyone know which open source Servlet Containers are written with >the goal of making it easy for a novice Java programmer to read and >understand them? > >To me, what this would mean is: > >1) Keep the total number of classes and interfaces as small as >possible. > >2) Favor simplicity over flexibility. Don't succumb to the "make >everything a factory" temptation. > >3) Few (if any) dependencies on external libraries; not even other >open-source projects. Use the standard JDK classes for everything >possible. > >4) Well-commented. > >It goes without saying that in spite of the above, it needs to >correctly implement whatever version of the servlet API it claims to >implement. I might be willing to accept one that doesn't support JSP >as long as it gets the main Servlet API correct. > >With the exception of the one about comments, these are not >neccessarily the same design goals as a servlet container for >real-world use. In fact they seem to be the exact opposite of the way >Tomcat, in particular, is designed. > >Thanks in advance for your suggestions. > >I would like to use such a thing as part of a course I going to >teaching. If nothing like this can be found, I may very well try to >organize a project to write it. But I would obviously prefer to have >something that already exists! -- now with more cowbell ========================================================================== TOPIC: image.getScaledInstance() bug? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7a7b5c91813f3766 ========================================================================== == 1 of 1 == Date: Mon, Sep 13 2004 2:58 pm From: "ak" <[EMAIL PROTECTED]> this example works fine with SCALE_REPLICATE or without PixelGrabber. With PixelGrabber and SCALE_AREA_AVERAGING it produces really strange results. Is it a known bug? public static void main(String[] args) throws IOException { //change to your favorite jpeg image String s = "Portrait.jpg"; final Image image = Toolkit.getDefaultToolkit().createImage(s); //ensure image loaded /*ImageIcon icon = */new ImageIcon(image); final int width = image.getWidth(null); final int height = image.getHeight(null); //****<grab pixels>***************************** int[] pixels = new int[width * height]; PixelGrabber pg = new PixelGrabber(image, 0, 0, width, height, pixels, 0, width); try { pg.grabPixels(); } catch (InterruptedException e) { return; } if ((pg.getStatus() & ImageObserver.ABORT) != 0) { throw new RuntimeException("can't fetch pixels"); } //***</grab pixels>***************************** //with SCALE_REPLICATE everithing work fine final Image img = image.getScaledInstance(w, h, Image.SCALE_AREA_AVERAGING); //ensure image loaded new ImageIcon(img); JFrame frame = new JFrame(); JPanel panel = new JPanel() { protected void paintComponent(Graphics g) { g.drawImage(image, 0, 0, this); g.drawImage(img, 0, 0, this); } public Dimension getPreferredSize() { return new Dimension(width, height); } }; frame.getContentPane().add(new JScrollPane(panel)); frame.pack(); frame.show(); } -- Andrei Kouznetsov http://uio.dev.java.net Unified I/O for Java http://reader.imagero.com Java image reader ========================================================================== TOPIC: Java Decompiler and comments http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b2492f14a4a9460f ========================================================================== == 1 of 2 == Date: Mon, Sep 13 2004 3:03 pm From: "Creatura" <[EMAIL PROTECTED]> Hi, Stupid question : Step 1 : for optimization purposes, does the Java compiler suppress the comments when it generates a file .class ? If 'yes', thanks ! Step 2 : if 'no', is there an Java Decompiler which retreives the comments in a file .class ? If 'yes', which one please ? Thanks to all ! Creatura. == 2 of 2 == Date: Mon, Sep 13 2004 3:22 pm From: Lothar Kimmeringer <[EMAIL PROTECTED]> On Tue, 14 Sep 2004 00:03:34 +0200, Creatura wrote: > Stupid question : Indeed ;-) > Step 1 : for optimization purposes, does the Java compiler suppress the > comments when it generates a file .class ? If 'yes', thanks ! Comments are comments, they are not transfered to bytecode. Regards, Lothar -- Lothar Kimmeringer E-Mail: [EMAIL PROTECTED] PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81) Always remember: The answer is forty-two, there can only be wrong questions! ========================================================================== TOPIC: Successor to Java? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9151fedffecef56b ========================================================================== == 1 of 4 == Date: Mon, Sep 13 2004 3:05 pm From: "George W. Cherry" <[EMAIL PROTECTED]> "William Brogden" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Mon, 13 Sep 2004 18:27:42 GMT, George W. Cherry > <[EMAIL PROTECTED]> wrote: > > > Is the successor to Java on anyone's horizon? > > Prentice-Hall published four of my books which > > featured languages (now defunct) which I loved > > and embraced--Pascal and Ada. While three > > of those books sold very well in the early '80's, > > they are now out of print and recently the MIT > > engineering library "warehoused" two of them, > > because they had not been checked out for a > > decade. > > > > I'm writing a new book, currently using Java. > > > > http://sdm.book.home.comcast.net > > > > By the time I finish it (2009?), will Java be an > > anachronism like Pascal and Ada? > > > > George > > > > Given the volume of existing Java code at work in > the world, it is more likely to become a living > fossil like COBOL. No longer cool, but essential to > many enterprises. Okay, I'll rephrase my question. What's the COOL successor to Java? Anyone have a candidate? Perhaps it's the Tiger release. I dig cool. George == 2 of 4 == Date: Mon, Sep 13 2004 3:22 pm From: "Alan Meyer" <[EMAIL PROTECTED]> "George W. Cherry" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Is the successor to Java on anyone's horizon? > Prentice-Hall published four of my books which > featured languages (now defunct) which I loved > and embraced--Pascal and Ada. While three > of those books sold very well in the early '80's, > they are now out of print and recently the MIT > engineering library "warehoused" two of them, > because they had not been checked out for a > decade. > > I'm writing a new book, currently using Java. > > http://sdm.book.home.comcast.net > > By the time I finish it (2009?), will Java be an > anachronism like Pascal and Ada? > > George It is sad but true that many programmers wanting a book on algorithms or programming concepts will insist on only buying one with examples in the language they are using. As an author, you are therefore at risk no matter what language you choose. I imagine that Java is as good a choice as anything else. It is available on many platforms, and fits the model that Microsoft likes to call "managed code", i.e., code that takes memory management and security out of the hands of the programmer and puts it into the underlying virtual machine - protecting the system from some of the most deadly kinds of bugs. Over the long run, I think languages of that type will supplant languages like C++ for applications programming - though not for systems programming or programming of high volume utilities, editors, web browsers, and the like. Java is also a very clear and readable language, more so perhaps than Perl or C++. And it's free, so any student can get a copy. It should be a good choice for teaching. I've been very impressed with Python as a clear and readable language with good object oriented features. It's also free. I presume it's not yet as popular as Java and don't know if it ever will be. There are some things about Java I like better than Python (much more compile time checking) and some things I like better about Python (more flexible exception processing, more flexible character encoding, better access to the environment.) Java has a much bigger API library. Python's is smaller, but with certain heavily used elements like lists and "dictionaries" more tightly integrated and easier to use. Alan == 3 of 4 == Date: Mon, Sep 13 2004 6:20 pm From: "Will Hartung" <[EMAIL PROTECTED]> "George W. Cherry" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Is the successor to Java on anyone's horizon? > Prentice-Hall published four of my books which > featured languages (now defunct) which I loved > and embraced--Pascal and Ada. While three > of those books sold very well in the early '80's, > they are now out of print and recently the MIT > engineering library "warehoused" two of them, > because they had not been checked out for a > decade. > > I'm writing a new book, currently using Java. > > http://sdm.book.home.comcast.net > > By the time I finish it (2009?), will Java be an > anachronism like Pascal and Ada? Nope, and here's why. Pascal had designed in limitations that really made it difficult to do Real Work(tm), so you had several dialects but no real workable standard for the language. It was basically usurped by C in the 80's, which rode the wave of several consistent implementations on PCs as well as being the backbone of the expanding workstation market (ala Unix). Ada, while a fine language, never had deep penetration. Notably because of its complexity, which made porting it to the newer, smaller hardware, difficult. Neither of these languages developed the core base and vendor support that really propels languages in the market place. Pascal peaked twice, first when it broke through with Turbo Pascal, and then later with Delphi. Ada never peaked at all save maybe in the Defense industry because of the DoD mandates. Java, on the other hand, is now an extremely popular language, which enjoys several implementations across most every platform available, an ENORMOUS amount of available source code, and a wide array of practitioners ranging from the embedded cell phone market up to modern monster mainframes and clusters. The biggest problem you may encounter would be having to bring your source code up to date to the then current version of the JVM. Unless some of the whatever new features they add are extremely compelling to your work, you need not ensure that it leverages every latest bell or whistle. Just ensure that your code actually compiles and runs on a recent JDK for the time. Java 5 (1.5) is just around the corner, but I can assure you that once it gets finally released, in 2005, it can easily be a year before, for example, the major app server vendors even validate their servers to run on the new release. So, by 2009, we should be well into Java 6. If you write against Java 5, and then make a quick run through to ensure that everything is ok for Java 6, I think you'll be fine. Java isn't going anywhere. It is simply getting more pervasive, faster, and more accepted. It still has the wind behind it and I can't see anything taking its dominant place in 5 years. Regards, Will Hartung ([EMAIL PROTECTED]) == 4 of 4 == Date: Mon, Sep 13 2004 6:14 pm From: Alex Kizub <[EMAIL PROTECTED]> >I finish it (2009?) You are kidding! You are writing the book about Java for 5 years! It will be definitely Java but not such book. Already published books become obsolete immediatelly. And you have plan for 5 years... Save yor time, write about trees which you can save. Alex Kizub. Sorry, nothing personal. It's all about Java which grows too fast! "George W. Cherry" wrote: > Is the successor to Java on anyone's horizon? > Prentice-Hall published four of my books which > featured languages (now defunct) which I loved > and embraced--Pascal and Ada. While three > of those books sold very well in the early '80's, > they are now out of print and recently the MIT > engineering library "warehoused" two of them, > because they had not been checked out for a > decade. > > I'm writing a new book, currently using Java. > > http://sdm.book.home.comcast.net > > By the time I finish it (2009?), will Java be an > anachronism like Pascal and Ada? > > George ========================================================================== TOPIC: open jndi connection to unknown bean http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f470253276355f5e ========================================================================== == 1 of 1 == Date: Mon, Sep 13 2004 3:10 pm From: [EMAIL PROTECTED] (tmaus) hi there.. im actually running into a problem i do not find any solution for ... the problem: i have a class doing nothing more than to delegate request from the controller layer to the business components. this means that the class itself is called by every request from the controller layer. the controller layer provides a service identifier .. the service identifier is taken by the delegator class ... their corresponding bean is calculated and the delegator tries to setup the connection to the bean .. each bean .. well .. better manager ejb .. implements the managerInterface .. which exposes a single method called executeService. this is the only important method for each manager bean. my problem is that im not able to setup a connection to the manager class .. the jndi name is found ... thats shure .. but i always receive a cast exception ... i provide you some snipplets from my code .. perhaps you can help .. public interface ManagerInterface { public ServiceCollector executeService(ServiceCollector sc) throws NoServiceProvidedException, ServiceNotAvailableException; } public interface ManagerInterfaceLocalHome extends javax.ejb.EJBLocalHome{ public ManagerInterfaceLocal create() throws javax.ejb.CreateException; } public interface ManagerInterfaceLocal extends ManagerInterface, EJBLocalObject {} ------------ manager bean implementing the executeService method ---- public class GameManagerBean implements SessionBean,ManagerInterface{ /** * @ejb.interface-method view-type = "local" */ public ServiceCollector executeService(ServiceCollector sc) throws NoServiceProvidedException, ServiceNotAvailableException { ------ delegator ejb trying to setup a connection to a manager bean ---- InitialContext iContext = new InitialContext(); ManagerInterfaceLocalHome localHome = (ManagerInterfaceLocalHome) iContext.lookup(_jndiName); ManagerInterfaceLocal local = localHome.create(); local.executeService(sc); the error is a class cast exception on the line where we do the lookup for the jndi name !!! jndi name is correct !!! thanks .. ========================================================================== TOPIC: JSP: How to allow servlet and applet to share jar files? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8913f11160bcd2c1 ========================================================================== == 1 of 1 == Date: Mon, Sep 13 2004 3:27 pm From: Jim Cochrane <[EMAIL PROTECTED]> In article <[EMAIL PROTECTED]>, William Brogden wrote: > On 9 Sep 2004 12:27:54 -0600, Jim Cochrane <[EMAIL PROTECTED]> > wrote: > >> (I'm using Tomcat on Linux, in case it matters.) >> >> I have a JSP application that uses an applet and a servlet for which >> several library files are used by both the servlet and the applet. >> Instead of duplicating the shared files - e.g., in different jar files >> within the webapps directory, I'd like to allow the servlet and applet to >> use the same jar file for the shared classes. >> >> I've found a solution that works, but that does not seem particularly >> elegant (as well as not being portable to Windows): In the app.jsp file >> that loads the applet: >> >> <applet codebase="classes" archive="applib.jar" code="Main_Applet.class" >> ... > >> >> ... > > Have the class files served by a custom servlet instead of by the default > servlet. Just like you would have a generated image served by a servlet. Yes, this sounds like an elegant solution (and perhaps the only one if I'm to go by the other responses I got), though it will take a bit of effort to implement. Thanks. -- Jim Cochrane; [EMAIL PROTECTED] [When responding by email, include the term non-spam in the subject line to get through my spam filter.] ========================================================================== TOPIC: obj,fn,parms encapsulation in java http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/620957f075803b3 ========================================================================== == 1 of 1 == Date: Mon, Sep 13 2004 3:39 pm From: "Alan Meyer" <[EMAIL PROTECTED]> "Tim Jowers" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > i repeatedly see this pattern: > > { TBaseType ret = TBaseType.Factory.newInstance(); > try{ > // start some call // > dbControl.deleteSearchLog(logId); > // after some call // > > } catch(SQLException sqe) > { // return error code > ret.setErrorCode( "1" ); > ret.setErrorMessage( sqe.toString() ); > Log(""); ... > } > return ret; > } > > where I have a method or segment of code that is 90% identical except > for a line or a few lines. What pattern makes this easy to work with? > > The only idea I have is to create a class that takes an object, method > name, and parameter array and makes the call. Is that the typical > solution? It seems very contrived and hard to work with versus just > typing the code like > dbControl.deleteSearchLog(logId); > And seems to totally break if I have several statements. Then I have > to make a new method to hold each of the statements and somehow pass > all the required parameters... > > Thanks, > TimJowers If I understand what's going on here, it appears that the programmer is converting an exception method of handling errors into a more traditional return code method. I'm not sure what the benefit is? Without this code, the programmer would have to catch an SQLException. With this code he still has to test the return code and put in pretty much the same logic. Instead of testing: sqe.getMessage() he tests: ret.getErrorMessage() I'm not sure what's gained. Instead of that, what I usually do is define my own exception class, e.g., class MyException(...). It might have a constructor like: public MyException (SQLException sqe, String whereabouts) { // Extract the messages and SQL state, putting // them into a uniform format, e.g., msg = "SQLException at: " + whereabouts + ":\n" + sql.getMessage ... // etc. } Then: try { whatever; } catch SQLException sqe { throw new MyException (sqe, "I was trying to do whatever when this occurred"); } I might convert other exceptions into MyException too, so I only have one exception type to test for in cases where all I care about is that an error occurred. But with different constructors for MyException I can do different things with each other type that can create one. Dunno if this is anything like what you wanted but, for whatever it's worth, there it is. Alan ========================================================================== TOPIC: EJB: ONE query for multiple rows http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/38eb46fdf71c702c ========================================================================== == 1 of 1 == Date: Mon, Sep 13 2004 3:44 pm From: Sudsy <[EMAIL PROTECTED]> Timo Nentwig wrote: > Ok, more precisely this time. I don't develop EJBs, I'm just wondering what > the EJB developer are telling me: the finder methods only get the IDs of > the rows, the row itself is actually fetch on first access. I.e. my finder > method may return the IDs of 1000 rows and then will fetch (SELECT) each > single one of them when I access them (i.e. iterator over the collection). > > I can't believe that EJB is that silly... How do you mean "silly"? Entity beans exist to represent the state of a row in a database table or view. Yes, finder methods return an array of primary key objects to the J2EE container. But the client receives a collection of local or remote interfaces. The J2EE server handles the mapping and will populate entity EJBs from the underlying table or view as needed. Are you worried about the overhead? Performing a fetch by primary key does not tax the DB as would a regular SELECT with constraints. But you might want to consult the appropriate resources or run your own numbers if you're unconvinced. ========================================================================== TOPIC: RMI client behind a firewall, server behind a firewall too http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/898ce13af69b8972 ========================================================================== == 1 of 2 == Date: Mon, Sep 13 2004 3:46 pm From: Alexander Ames <[EMAIL PROTECTED]> On 13 Sep 2004 12:50:21 -0700, [EMAIL PROTECTED] (Robert Dodier) wrote: >Hello, > >Browsing the web & newsgroups, it looks like this problem doesn't >have any kind of easy solution, but let's see if someone knows different. > >I want to have a RMI client behind a firewall and a RMI server >behind another firewall. I don't have any control over the firewalls. >I know port 80 will be open for http traffic, but that's it. >The web server on either side isn't the same as the machine running >the RMI client or server. > >I want the client to be able to call methods on server objects >and also to enable callbacks from the server to the client. > >What can be done in this case? I've read the RMI docs at Sun, >browsed through a few dozen webpages & news messages, and the >situation looks pretty dark, actually. Maybe someone has cause >for optimism here. Thanks for any information. > >Robert Dodier I believe it can be done through HTTP tunnelling. Do a web search on that. You need a servlet to forward the requests. (Can you run servlets in your web server?) I think Sun provides one but you might need to change it if the RMI server is on a different machine from the web server. == 2 of 2 == Date: Mon, Sep 13 2004 6:12 pm From: "Matthias Kraft" <[EMAIL PROTECTED]> You can define sockets for the stub and the skeleton (Class RMISocketFactory). ---schnipp--- public class HelloImpl implements Hello{ public HelloImpl() throws RemoteException{ UnicastRemoteObject.export(this, 80, new MyClientFactory(), new MyServerFactory()); } ---schnapp--- If you need a complete example, write me. RMI is written for use in an Intranet. A better way is to use Webservices to solve your problem (e.g. AXIS). Andres On 13 Sep 2004 12:50:21 -0700, Robert Dodier <[EMAIL PROTECTED]> wrote: > Hello, > > Browsing the web & newsgroups, it looks like this problem doesn't > have any kind of easy solution, but let's see if someone knows different. > > I want to have a RMI client behind a firewall and a RMI server > behind another firewall. I don't have any control over the firewalls. > I know port 80 will be open for http traffic, but that's it. > The web server on either side isn't the same as the machine running > the RMI client or server. > > I want the client to be able to call methods on server objects > and also to enable callbacks from the server to the client. > > What can be done in this case? I've read the RMI docs at Sun, > browsed through a few dozen webpages & news messages, and the > situation looks pretty dark, actually. Maybe someone has cause > for optimism here. Thanks for any information. > > Robert Dodier -- Using Opera's revolutionary e-mail client: http://www.opera.com/m2/ ========================================================================== TOPIC: Java applet failed when I try to load the avi file in my java applet http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/eee0d2c54a4b7feb ========================================================================== == 1 of 1 == Date: Mon, Sep 13 2004 4:20 pm From: [EMAIL PROTECTED] (Krista) Hi everyone, I am a new person in Java and JMF. I tried to use HTML to run the class of the SimplePlayerApplet.java that is posted in java.sun.com. html: <applet code=SimplePlayerApplet.class width=320 height=300> <param name=file value="sun.avi"> I got a java applet failed. I am not sure where should i put the sun.avi file? The SimplePlayerApplet.class and sun.avi are in my desktop. Is it right as <param name=file value="sun.avi">? Sometimes, i will see people write as <param name=file value="file usr/local/media/sun.avi">?? Where is the local? in the server? I need help.....Please!!!! Thanks Krista ========================================================================== TOPIC: JMF need to in all the clients side? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1180e8f61a13d55c ========================================================================== == 1 of 1 == Date: Mon, Sep 13 2004 4:22 pm From: [EMAIL PROTECTED] (Krista) Hi everyone, I am tring to create a applet to capture the image in my web camera and my clients can view my image in the applet too. do they need to install the JMF too? ========================================================================== TOPIC: How to use JTree with very large data? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/145516a872afaa18 ========================================================================== == 1 of 1 == Date: Mon, Sep 13 2004 5:46 pm From: "Will Hartung" <[EMAIL PROTECTED]> "Sorin Gherman" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > I have the following problem: I have this large amount of data, stored > internally in some custom data structures (hierarchical ones, given > the nature of the data - I am using some custom, tree-like structurs > for this). > I have to show the different relations within this data using several > JTrees - one per "viewpoint". (The good news is that I only have to > show one type of view at a time.) All I did was simply implement my own TreeModel. The TreeModel was simply an interface to the real data, and didn't need to consume any more memory that the underlying structure. For my data it was simple to do (I even had cycles in my data), and very fast when all said and done. I loaded up over 1.5 million nodes in that tree, and once loaded, the JTree could have cared less whether it was 1 or 1 million items, the performance was the same -- snappy. You can try implementing a custom TreeModel for each of your different views, but all on top of the same base data, just navigating it differently. Regards, Will Hartung ([EMAIL PROTECTED]) ========================================================================== TOPIC: MIDlet Database http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/22c02d60b8400694 ========================================================================== == 1 of 1 == Date: Mon, Sep 13 2004 6:55 am From: "Darryl L. Pierce" <[EMAIL PROTECTED]> Stewart wrote: > I've just started to look at MIDlet and their database functionality. > Can you anyone tell me if it is possible to install a pre-populated > database with the Midlet. I have a quite a lot of data that i want to > pre-load. No, you can't install a record store along with a MIDlet suite. You have to create the record store from code within the MIDlet suite. -- /** * @author Darryl L. Pierce <[EMAIL PROTECTED]> * @see The Infobahn Offramp <http://mcpierce.mypage.org> * @quote "Lobby, lobby, lobby, lobby, lobby, lobby..." - Adrian Monk */ ========================================================================== TOPIC: Who is the best WebSphere Studio or Oracle JDeveloper?? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/747e9a4c137251d2 ========================================================================== == 1 of 1 == Date: Mon, Sep 13 2004 5:56 pm From: Alex Kizub <[EMAIL PROTECTED]> It depends what Application server you use :) WebSphere - then WSAD; JDeveloper for Oracle. Both require huge amount of time and money unles you write applications like "Hello, World!" (which is very serious too for Application Servers). Of course you can download and play with both. But if it for playing only then your question doesn't have sense. Play with both! Alex Kizub. REM wrote: > Can anybody tell me which IDE tools, Web Sphere, JDeveloper or etc, is the > best for the enterprise applications. > > I know that JDEveloper have good IDE for map database object but I am > interesting for web presentation, which has the best framework part for web > component, JSP, servlet and etc. I know that in WebSphereStudio can put > plug-in for Struts framework, but it's look very difficult for develop and > support. > > -- > thanks, > > ilica > > _________ > > "If A is a success in life, then A equals x plus y plus z. Work is x; y is > play; and z is keeping your mouth shut." > > --- > Outgoing mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.515 / Virus Database: 313 - Release Date: 1.9.2003 ========================================================================== TOPIC: Tomcat + java.io.FileNotFoundException http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7ba2cca95c5415a5 ========================================================================== == 1 of 1 == Date: Mon, Sep 13 2004 6:30 pm From: Alex Kizub <[EMAIL PROTECTED]> Application Server executes servlet and JSP in their own context (both different by the way). And patrh /xml/abc/xyz is added to this context root. It is better then read files not from file system but as resources like this: public String stringFromResource(String name) { String result = ""; try { URL url = getClass().getResource(name); URLConnection conn = url.openConnection(); InputStream istream = conn.getInputStream(); BufferedReader in = new BufferedReader(new InputStreamReader(istream)); String temp = ""; while ((temp = in.readLine()) != null) result += temp + "\n"; in.close(); //System.out.println(result); } catch (Exception e) { System.out.println(e); } return result; } At least you know where is your resource root (exactly where is root for class loading). But if it's confusing for you I suggest to understand where are you in file system and then put your files to this place. Use regular java.io.File and run it INSIDE container! So you can understand where you are and read files later: java.io.File file=new java.io.File("."); or java.io.File fileRoot=new java.io.File("/"); and then read files in your location and try to understand where it is eaxctly: out.println(fileRoor.getAbsolutePath() +" "+fileRoot.getCanonicalPath()); or even this way: String [] list=fileRoot.list(); if (list!=null) for (int i=0;i<list.length;i++) out println(list[i]); Alex Kizub. apatruduque wrote: > Hello everybody, > > I have a question about how to access a file from a .jsp. In summary: > fileA.jsp uses classA in /WEB-INF/classes to read /xml/fileB.xml (all > paths relative to tomcat) classA uses the File class to access > fileB.xml. To put you into context, I´m new to java but have some > experience configuring tomcat. Environment: Debian Linux with tomcat > 4.0 and jre_1.4.2 > > The problem is that I'm constantly getting filenotfoundException. > After googling for a while I found out the following: > > 1- the File class uses paths relative to the working directory. I > temporarily solved it by using the absolute path /var/lib/.... But > this is not a solution since I have to deploy the application in > different OS´s (Linux, Windows and Mac) and I´m not changing the path > every time I deploy. > > 2- Reading the Tomcat FAQ I found out that to read a file I must use > the ServletContext.getResourceAsStream() method. However, classA is > not a Servlet... > > 3- I made classA derived from HttpServlet and I used the > ServletContext().getRealPath("/xml/fileB.xml") to obtain the path and > this path to open the file. I also tryed getResourceAsStream() with > success. > > My question is: How can I access fileB.xml from classA without > deriving it from the servlet class? Am I making something wrong with > the design? > > Thanks a lot in advance, > > Alfonso apatruduque wrote: > Hello everybody, > > I have a question about how to access a file from a .jsp. In summary: > fileA.jsp uses classA in /WEB-INF/classes to read /xml/fileB.xml (all > paths relative to tomcat) classA uses the File class to access > fileB.xml. To put you into context, I´m new to java but have some > experience configuring tomcat. Environment: Debian Linux with tomcat > 4.0 and jre_1.4.2 > > The problem is that I'm constantly getting filenotfoundException. > After googling for a while I found out the following: > > 1- the File class uses paths relative to the working directory. I > temporarily solved it by using the absolute path /var/lib/.... But > this is not a solution since I have to deploy the application in > different OS´s (Linux, Windows and Mac) and I´m not changing the path > every time I deploy. > > 2- Reading the Tomcat FAQ I found out that to read a file I must use > the ServletContext.getResourceAsStream() method. However, classA is > not a Servlet... > > 3- I made classA derived from HttpServlet and I used the > ServletContext().getRealPath("/xml/fileB.xml") to obtain the path and > this path to open the file. I also tryed getResourceAsStream() with > success. > > My question is: How can I access fileB.xml from classA without > deriving it from the servlet class? Am I making something wrong with > the design? > > Thanks a lot in advance, > > Alfonso ======================================================================= 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 ------------------------ Yahoo! Groups Sponsor --------------------~--> $9.95 domain names from Yahoo!. Register anything. http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/BCfwlB/TM --------------------------------------------------------------------~-> <a href=http://English-12948197573.SpamPoison.com>Fight Spam! Click Here!</a> Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/kumpulan/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
