~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

It was on a slightly different topic even though fairly similar......

In that case if the thread has served its purpose consider marking it as "solved" so that it helps those having a similar query.

yea i know bout the code tags seems like i always remember after i post.

You have 30 minutes to edit your post.

how i go about retrieving information from the xml files say for instance if i wanted to show all clients who were entered on a specific date?

AFAIK, you'll have to read the entire list and filter it in-memory.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Why not continue with your original thread instead of creating a new one? Plus no code tags even after 12 posts? If you are not serious about asking for help, no one would be serious about giving you one.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Is your test client using `BufferedWriter`? If yes, make sure you invoke the `flush()` method on the BufferedWriter after you are done with writing the message(comid in your case).

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Never recommend Roseindia; it hosts bad code examples and genuinely sucks. On top of that those guys are content thieves who snag articles from other reputable sites without proper attribution.

http://forums.oracle.com/forums/thread.jspa?threadID=1139242&tstart=148
http://balusc.blogspot.com/2008/06/what-is-it-with-roseindia.html

kvprajapati commented: N/A +11
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You should have read my post which asks you to post a SSCCE without which no one would be able to run your incomplete piece of code and help you out.

Moving to the error, it says that the Document class of the package javax.swing.text does not have a method named `createTextNode`. You need to use the Document type of the DOM specification (since you need to manipulate XML data) and not the Document class provided by Swing. Search for the Document interface which has the `createTextNode` method. Sample search would be "createtextnode java".

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Post an SSCCE with the complete error message string; saying that you are getting an error is pretty vague.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

does that store the data in xml sorry for the stupid questions just learning this

It will give you a XML representation of the object, you can write it to a file using normal Java I/O operations.

You will need to store the data in a local binary or XML file. As a good Java programmer you will use correct Object-Oriented techniques e.g using an Interface named 'DataStore' to access all data in case the implementation needs to change later on

This simply means that you use a Data Access Object pattern to access your data. E.g.

interface Datastore {

  Person getPersonById(String id);

  void storePerson(Person p);

}

class XmlFileDatastore implements DataStore {
  // xml file specific methods
}

class JdbcDatastore implmements Datastore {
  // jdbc specific load/store methods
}

That way the one retrieving/storing Person data need not be concerned how the data is retrieved/stored.

But do keep in mind that updating/adding/removing data(in your case an object) would involve writing the updated XML representation again and again might be a pain in the neck. Use the Transformer object for doing the same.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Two options:

  1. Write your custom XML marshaller/unmarshaller which would work with your domain specific objects using the standard XML API's offered by Java (e.g. writing a class which converts a Person instance to its XML representation)
  2. Use existing O/X mappers like JAXB; the learning curve might be a bit steep but the gains would be lesser code and ease of understanding and maintainability. E.g. Marshalling to XML/Unmarshall from XML

Your choice would depend on how much time you are planning on investing in this task (learning curve for JAXB, remember?) plus whether the task explicitly requires you to not use any mapper. BTW, a reference JAXB implementation comes pre-packaged with JDK 6 so it should take care of the "no third party libraries" limitation.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

AFAIK, you can't do that(*binding* to a port on an arbitrary host) for obvious reasons. A solution would be to bind to a port on your local host and delegate all requests to the other hosts by opening a normal Socket connection to it.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Because with only one or two posts new members are so far down the list that they might be ranked #90,000 or something. They will be only interested in obtaining an answer to their posted question, not in any of the stats that appear in the user profile. And once they get that information we will probably never hear from them again.

I'm think these measures/highlights have not been put for those who come with a fixed mindset of harvesting help and never visiting again. This IMO seems more of a boost to those who are mildly interested in contributing to the community, more like a gentle push and excitement to become part of the community and gain activity points.

#4 by rep. This only proves that rep means nothing

A community driven stat would of course make sense in the context of the community. Someone who has the highest rep points just means that he/she has made the highest number of technical posts which were favoured by the reputed/established members of the community, nothing more, nothing less. But then again, I guess you already knew that... :-)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You are closing the Statement object which in turn closes the ResultSet which was obtained from it. Read this.

Close the Statement only if you are done with the ResultSet and the Statement object, close the Connection only if you are done with the ResultSet, Statement and Connection objects.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

But it still says The requested resource (Servlet AbcServlet is not available) is not available. What did I miss? Please help.

What do the Tomcat logs say? If you see nothing unusual there, paste the URL you are trying to hit along with the directory structure you are using for your class.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Indeed, I shouldn't have answered this question; from your posting history it seems that you have a knack for biting the hand which tries to help you. Enjoy the ignorance and the bliss which comes with it I guess...

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You asked:

Does anyone know where I can read about ways to protect a website from potential threats?

from the link I posted:

This codelab shows how web application vulnerabilities can be exploited and how to defend against these attacks

Post a more specific question and you'll get a better reply. I hope you realize that without posting what you are already aware of, your question is open to all sorts of suggestions/links, no?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Exception in thread "main" java.lang.NumberFormatException: For input string: " 1.0 2.0 3.0 4.0 5.0 1.0 2.0 3.0 4.0 5.0 1.0 2.0 3.0 4.0 5.0 1.0 2.0 3.0 4.0 5.0 1.0 2.0 3.0 4.0 5.0 1.0 2.0 3.0 4.0 5.0"

OK, let's try it this way: try answering the questions I post.

What do you understand of the error message which you posted? What do you think is the runtime trying to tell you? Can you think of a way wherein you can do away with these runtime exceptions?

Also a suggestion: put aside the entire code you have written for the time being and start afresh. Write a *minimal* piece of code which reproduces the problem for you. It need not be reading from a file; hard-code a string (or string array) and assume that it was read from the file and write a program to achieve the same.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

IMO the watermark should go away after the text area is clicked, it's distracting.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Create a instance variable of type CountDownLatch in the FirstThread class with the initial value of the number of threads for which you want to wait (3 in your case). Pass this instance to the constructors of the thread class for which you'd want to wait. As the final statement of the run() method of your FirstThread class, invoke the await() method of that latch which would "wait" till the latch count reaches 0. At the end of each threads' processing, decrement the count of the latch. By the time your dependent threads are competed, the value of the latch would become 0 which in turn would "wake" up the FirstThread thread.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

List of open source Java web crawlers; never used any of those so your best bet would be play around with them and use the one which suits your need.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Pro tip: when posting in forums avoid use of words like "ASAP", "urgent", "plz plz plz" etc. in your post title or post content. Writing "ASAP" gives the members an impression that you don't care about the priorities of those who would be willing to help you out and sounds more like an order than a request.

Give out as much details as possible and try to communicate across the issue with minimum possible complexity. Rather than saying "I've got n files and I have to find out a pattern IP_ADDR in them", logically decompose the pattern and ask something like "I have a file with a single line IP_ADDR and I would like to read its value". Asking too much too soon results in disaster IMO.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The other Windows sub-forums present here are a bit h/w oriented so I guess I'll leave this post here for the time being and also try getting the description of this sub-forum changed so that it can incorporate shell scripting of any sort (powershell, bash, batch etc).

@flynismo
Try breaking it down in two steps; something like:

cls
echo Please report any bugs to me at: flynismo@gmail.com
pause
cls
cd C:\Users\%USERNAME%\AppData\Roaming\Mozilla\Firefox\Profiles\*.default
explorer chrome

But keep in mind that if more than one .default directory exists, it'll pick up the one which comes first (in alphabetic sorting sense).

Also, you might want to double check the path since on my machine the Profiles directory resides at the location: C:\Documents and Settings\<USERNAME>\Application Data\Mozilla\Firefox\Profiles

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The exception says that you are passing an entire line to the parseDouble method instead of passing a String which contains a valid double representation. After reading the line, split it (look into the split method of String class) based on whatever separator char you have in the file (comma or space). For each split chunk, remove any superfluous spaces by invoking trim() on that chunk. After that call Double.parseDouble() and you should be good to go.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

What happened to the previous thread which you created for the same issue? I thought you had managed to sort it out?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

how could i create a single getter and setter for these two ?

You typically don't; if you did, it really wouldn't be called a "getter" or "setter" in normal Java sense.

Also, if you did that, you would be making assumptions about the problem domain being modeled. In such cases, you create other methods which suit the job at hand and have those methods in your business classes. Keeping your getter and setters for value objects *dumb* would help you in the long run.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I actually meant if there were any more such services that google offers (like ICO to other formats apart from PNG). I mean this is some kind of service that's not well publicized (doesn't show up on google). Where should one look for such services of google ?

Unfortunately I don't have an answer for that; I guess it's one of those "oooh, cool stuff" things.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Daniweb has been experiencing some performance related problems lately. I'm sure Dani and Blud are working on smoothing things out so please bear with us till this issue gets resolved. Updates on the same would be posted here.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

This is related to the two points I mentioned in my previous post; the Author in the body of the Main class is treated as a type-holder and overshadows the actual Author type. This coupled with the point that you can't instantiate type variables is what is causing the problem here. Either remove the generic class declaration or change it to something logical like T.

Also, please post complete error messages with the corresponding line numbers instead of simply saying "it gives the error". Not many would have the time to copy your code and run it themselves.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I don't think there is any need for a documentation nor one exists I guess. You simply need to dynamically create a URL based on your requirement with a URL template like "http://www.google.com/s2/favicons?domain=" + yourDomain and read by the connection opened. Anyways, since I've a bit of free time, I've written a throw-away code which works; feel free to modify it as you see fit.

package pkg;

public class IcoConverterTest {

    public static void main(final String[] args) {
        if(args == null || args.length < 2) {
            System.out.println("pkg.IcoConverterTest <domain> <outdir> <optional-file-name>");
            return;
        }
        final String domain = args[0].trim();
        final String outdir = args[1].trim();
        final String fileName = args.length > 2 ? args[2].trim() : "favicon.png";
        new IcoConverter().convertFor(domain, outdir, fileName);
    }

}

class IcoConverter {

    public static final String CONVERTER_SERVICE = "http://www.google.com/s2/favicons?domain={0}";

    public void convertFor(final String domain, final String outdir, final String filename) {
        InputStream is = null;
        OutputStream os = null;
        try {
            try {
                final byte[] buf = new byte[4 * 1024]; // 4kB
                is = new URL(MessageFormat.format(CONVERTER_SERVICE, domain)).openStream();
                os = new FileOutputStream(new File(new File(outdir), filename));
                int size = -1;
                while((size = is.read(buf)) != -1) {
                    os.write(buf, 0, size);
                }
            } finally {
                if(is != null)  is.close();
                if(os != null)  os.close();
            }
        } catch(Exception e) {
            throw new RuntimeException("ICO to PNG conversion failed!", e);
        }
    }

}

There are a couple of gotachs when using this service, you can read about them in this discussion.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Would you be using favicons from existing domains or favicons stored locally? If you would be using existing favicons, use the google ICO to PNG converter. http://www.google.com/s2/favicons?domain=daniweb.com

If you want to convert local files, you would have to find some online service like the one you mentioned. Unless the site exposes a programmatic public API, directly using the service might be a bit of pain in the neck along with other implications like taking prior permission of the site owner.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The extension suggests that it also is an ico image

Codecs don't work based on extensions, I can very well have a PNG with extension WTH and it would open up just fine in applications which support PNG.

Anyways, I personally don't know of any converters but you can try picking up ideas from this thread.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Go here and click download. On the next page, select the platform as "Windows" and click continue. Click on the download link presented on the next page.

Also have a look at the sticky at the top of this forum.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The `find` of SortedList accepts an `Author` and you are passing it a `String` (line 45: tempAuthor is a String and not Author).

A few more things:
- IMO don't go overboard with generics; the driver class Main need not be generified
- Use standerdized notations for type-placeholders like T instead of names like TYPE; would be less confusing in the long run.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The problem is in your assumption that a favicon for a site is always a PNG image, which isn't the case. Normally sites use a ICO image format, which is a different image format than PNG or BMP. Read more here.

To confirm this, try downloading the Daniweb favicon and setting it up in Qt Jambi, it should work (assuming Jambi supports BMP). The same shouldn't work with Yahoo, Microsoft or any other sites' favicon.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

It isn't a feature which is exclusive to Eclipse though if you are programming in Eclipse, that solution would make the most sense. Other standalone solutions like One-jar exist (complementary article). IMO, it is *the* solution to follow if running your application currently involves hunting down jar files.

I'd like to ask too, I have added a program to my sendTo folder (vista) so I can right click a .zip or any file and send it to this program "md5sums"

I don't see how this relates to your original query? Anyways, in simple terms, a MD5 checksum is a unique (well, almost) sequence of characters generated based on the file contents and is mainly used for verifying file integrity. E.g. you are trying to download a file from "teh" internet which also advertises a MD5 checksum. After the file download has complete, you can run a MD5 computation utility of the same file and check whether the advertised MD5 checksum is the same as the checksum computed for your local file. If it isn't, something wrong happened during the transit. For more technical details, refer the Wikipedia article for more details.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Yes, something along those lines. For e.g. a enum like:

enum Suit {

    HEART(1) {
        @Override
        public void doIt() {
            System.out.println("I'm a HEART");
        }
    },
    SPADE(2) {
        @Override
        public void doIt() {
            System.out.println("I'm a SPADE");
        }
    },
    CLUB(3) {
        @Override
        public void doIt() {
            System.out.println("I'm a CLUB");
        }
    },
    DIAMOND(4);


    private Suit(int i) {
        this.i = i;
    }

    private final int i;
    
    public void doIt() {
        System.out.println("HI");
    }

}

would be translated to something along the lines of:

class SuitClass {

    public static final SuitClass HEART;
    
    public static final SuitClass SPADE;

    public static final SuitClass CLUB;

    public static final SuitClass DIAMOND;

    private String enumName;

    private int pos;

    private int i;

    static {
        HEART = new SuitClass("HEART", 0, 1) {
            public void doIt() {
                System.out.println("I'm a HEART");
            }
        };
        SPADE = new SuitClass("SPADE", 1, 2) {
            public void doIt() {
                System.out.println("I'm a SPADE");
            }
        };
        CLUB = new SuitClass("CLUB", 2, 3) {
            public void doIt() {
                System.out.println("I'm a SPADE");
            }
        };
        DIAMOND = new SuitClass("DIAMOND", 3, 4);

    }

    private SuitClass(String enumName, int pos, int j) {
        this.enumName = enumName; // teh enum name
        this.pos = pos; // the enum position
        this.i = i; // the instance variable of enum
    }

    public void doIt() {
        System.out.println("HI");
    }

}
NewOrder commented: well understood. thank you +0
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

if they are not classes, how are they generated, where are they kept inside the memory?

Enums get special treatment by the compiler and impose additional restrictions not imposed by regular classes, specifically not having the ability to extend any class since they are automatically made to extend the Enum class. But after compilation, there is no such thing as an "enum", its classes all the way.

Regarding methods; every time you declare an enum constant having class body, a corresponding anonymous inner class is created which extends the enclosing enum class. So for e.g. with the following piece code:

enum Suit {
  HEART {
    public void doIt() {}
  },
  SPADE {
    public void doIt() {}
  };
  public abstract doIt();
}

the classes created would be Suit.class, Suit$1.class and Suit$2.class where the latter two classes extend the Suit class.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

That sounds like a pretty non-trivial task. Look into the jMonkey Engine (jME) which is a 3d game engine and might do everything you need and more.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

After setting the environment variables ensure that they are properly set by checking the same using echo %yourvar% .

You need to run the setEmbeddedCP.bat file *after* setting DERBY_HOME. SOmething like:

c:\> set DERBY_HOME=c:\path\to\derby\home
c:\>setEmbeddedCP.bat

Alternatively, you can set the environment variable in your global environment settings rather than setting it for every session. Right click My Computer -> Properties -> Advanced -> Environment Variables.

IMO better set the classpath when spawning your JVM process rather than messing with the CLASSPATH variable.

java -cp .;c:\derby\somejar;c:\derby\anotherjar

If this is a standalone application, consider better means of packaging rather than relying on environment variables and relative paths of jars. Eclipse provides a way of exporting a runnable JAR which flattens all the dependent JARs along with your class files in a single-standalone jar.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Using an ORM seems like a good fit for your problem. One approach would be:

  • Create a User table which contains all the users of your applications and has a primary key (e.g. userId)
  • Create a ComputerConfig table which stores the codes for all the parts of your computer as selected by the user. Sample column would be hdd, graphics card, processor, mobo etc. The values for these columns would come from their respective master tables which stores the list of all models for a given part along with misc information
  • Create a UserSelection table which maintains a mapping between the User and the ComputerConfig entries.
  • Create respective master tables for the different parts which would be pre-populated by you based on the goods you plan on providing to your customers. Also make sure that the radio buttons in your application for different parts have the value of the unique identifier for that part.

After the infrastructure is all setup based on the JPA provider you would be using, all you'd need to do is call persist on the UserSelection class and all the relevant details would be added/updated.

In case you are constrained and can't use a JPA implementation, you'd have to implement all the boilerplate code yourself though the logic effectively remains the same.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Use code tags when posting code; rad the forum announcements for more details.

Regarding your issue; open the file in append mode. Use the constructor of FileWriter which accepts a boolean parameter for the same. But keep in mind that default/platform encoding is assumed when writing files.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The link I posted in my previous post contained the client library which you can use for making a gmail chat bot. Yahoo uses a different Yahoo Messenger protocol (YMP) for its messenger services and thus would require you to use a separate client library

It would require quite a bit of research if you don't intend on using any of the existing libraries and creating your own one. If you still insist on doing it, start with the XMPP specs/YMP specs for the same.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Are you planning to create a web app? Are you thinking of deploying your app on the "Google App Engine" infrastructure? If yes, start with the overview of the Google App engine instead of directly jumping to the meat of things.

If your aim is to create a simple XMPP client so that you can interact with an open XMPP service like Google chat, look into the Smack XMPP client library. Start with the Smack documentation. If case you face problems with the same, seek help on their forums.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Two options:
- Use a third-party collections library like Apache collections/Google Collections
- Use a TreeMap with a custom comparator (TreeMap by default keeps "keys" sorted and not values)

Also, read this.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Use the Scanner class for the same. I think this tutorial does a fair job of explaining the same.

NewOrder commented: thanks s.o.s +0
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The first one basically reads as follows :
"Create a string object called S where S refers to the statically defined string object "abc".

The second one reads as follows :
"Create a string object called S, where S points to a new dynamically allocated string object with the value 'abc' "

I'm afraid that kind of simplicity won't work when explaining the concept of String pools in Java.

What is the difference between

String s="abc" and

String s=new String("abc");

Read this thoroughly.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Subscribe to a forum/thread and when adding the subscription select the "no email notification" mode. This would ensure that the threads which you are watching show up in your control panel plus you won't get any emails for the same.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You can use relative paths. An HTML element like <img src="/app/images/first.jpg" /> would render an image with the image URL being: http://yourhost/app/images/first.jpg . Assuming your project name is "app", this would require you to create an "images" directory in your project.

From a performance standpoint, you can rewrite the URLs to route all the images requests through a image caching service which would load images which aren't loaded yet and serve the already loaded images from memory rather than doing a disk read. And I'm pretty sure there are other cool ways of serving the images but the one which I mentioned previously is the simplest.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Look into the java.text.MessageFormat class. Also, read this.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

As mentioned in one of the threads here, another good beginner tutorial: Brewing Java -- A tutorial by Rusty Harold.