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

I'm not sure if I understand your question here but to get around the tedious act of escaping properties-file-sensitive-characters, consider writing your properties file in XML format. The entire code remains the same with the exception of the way you write down your properties. Not requiring the user to escape spaces, quotes, double quotes when configuring data in a properties file is a big win IMO.

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

What's up with the INT(3) for the age column? If you explicitly plan on specifying the precision and scale, use the NUMERIC data type since INT doesn't support it or else just stick with INT (without the precision in brackets) which has a defined range. Read more about numeric data types in Derby here.

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

> why can I not use 2 different variables and display the interger values
> of each array? System.out.println(Arrays.toString(myIntArray)); .

> how can I continue work with the return value false/true from
> Arrays.equals(initialstate, goalstate).

Sorry but this isn't clear. What exactly do you mean by 'how can I continue'? Post the code which are trying to run along with what is expected and what you are getting.

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

> i want to know that whether Calender.getInstance() method is
> threadsafe or not.

AFAIK, yes, it is. Thread safe concerns normally crop up when you have destructive updates happening to an object. Calendar.getInstance() is a static method and doesn't alter any static fields of the Calendar class and hence is thread safe.

A word of advice though; just because a method is labeled thread safe doesn't mean you can use the corresponding class and always have correctness in your application. A classic example is the Vector class which has its `get`, `set, `size` methods synchronized but still has the possibility of exhibiting incorrect behaviour when used in your *custom* scenario. E.g.

if(vector.size() > 0) {
  // some complicated processing
  Element e = vector.get(0); // can fail!
  // Since by the time the control reaches here,
  // some other thread might have already modified the vector.
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

For all regular usage, you would want to use the Calendar and java.util.Date classes. java.sql.Date class is normally used in JDBC context. Read this. You get the error because java.sql.Date doesn't have a no-arg constructor.

BTW, which class has this 'SendFile' method of yours? Is it in a separate class or in the same servlet? If it's in the servlet, post the entire servlet class definition.

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

FTP supports a mget command which can be used for retrieving multiple files based on the passed in file name/pattern. Look into your FTP client documentation for such support.

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

I sent a pm with what this is regarding. Is there anyone I can contact who can remove or edit this?

We can't delete this thread as per the site rules/acceptable use policy. You asked for help, you got help. Deleting this thread would deprive others of the hard work done and the time spent by jcao219 in answering this thread.

Quoting the 'Acceptable use policy' of this site:

Additionally, DaniWeb LLC reserves full rights and privileges to information posted to anywhere within the daniweb.com domain by its members and staff. Any and all information posted on DaniWeb may not be copied or used elsewhere, in any way, shape, or form, either on the Internet or in print, without prior written permission from Dani Horowitz.

In case your instructor demands an explanation, you are more than welcome to re-direct him to this post.

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

Aspell is a GPL'ed spellchecker which is pretty famous and used in chat clients like Pidgin. You can try their mailing list/forums for more details on integrating it with your Java application.

There is another Java library called Jazzy which is a spin-off of the Aspell project which you might interested in having a look at.

Edit: Doh, beaten by Peter. :)

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

Yes, post the user name you desire along with an alternate one in case the former is already taken.

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

IMO giving a thread title like "Hijack Attempt #2 -- Do this for me. I can't be bothered" doesn't solve anything. At best, it seems like an attempt to make others laugh by mocking at the OP, certainly not expected of a group of people who are responsible for looking after a community, however good or bad it may be. Closed. :(

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

> Would it be a null?

Yes, it would be a null. In such cases, it helps to think of arrays as just another class containing a list of values rather than a provision built in the language itself.

class ArrayOfInts {
  // for every ArrayOfInts object created, i will be 0 by default
  private int i;
}

class ArrayOfBooleans {
  // for every ArrayOfBooleans object created, i will be false by default
  private boolean i;
}

class ArrayOfPoints {
  // for every ArrayOfPoints object created, i will be null by default
  private Point i;
}

I'd personally work with a fixed size ArrayList of points and if needed, invoke the toArray method to get the underlying array. Much easier and cleaner IMO.

List<Point> points = new ArrayList<Point>(13);
points.add(new Point(12,12));
// and so on
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

When you define an array, the array elements are given their default values which depends on the type of elements the array holds. For booleans it is false, for integers it is 0, for reference types it is... :)

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

> btw, how do we view a list of past 'members of the month

You can view the newsletter archive here which also has the member of the month interviews.

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

The problem here is that instead of having the commons jar file in the WEB-INF/lib folder, you have a commons-lang folder. This doesn't work for the simple reason that it's the jar files in the WEB-INF/lib folder which are on the classpath and not the jar files which are present in any of the sub-directories of the WEB-INF/lib folder. Move just the commons-lang-2.5.jar file directly under the lib folder and it should work out to be fine.

talha06 commented: Thank you so much for your helps and patient. +1
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The screenshot you have attached shows compile time dependencies...

OK, let's tackle this in a different way. Right click on your project -> Export -> Web -> War File and export your project as a WAR file. Browse this WAR file (just like any other archive) and see if you can see your jar files in the WEB-INF/lib directory. If you can't, then there is something wrong with the way you have configured your project.

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

You should never add any application specific jar to your server's lib folder; add them to the `lib` folder of your WEB-INF folder. And the ClassNotFoundException is a clear indication that specified class is not on your runtime classpath. Also, post the entire stack-trace for reference.

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

Is it in the lib folder of WEB-INF? It'd be difficult to suggest anything without looking at the actual project structure. Have you tested this out with a standalone application? Are you using an IDE to develop and run this web app?

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

The error is exactly what it says, the classloader was not able to locate your class. Where have you placed the Hibernate jar files?

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

Look at the source code of the existing collection classes in Java to see how you can implement your own generic collection type. Also, read my reply here.

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

> I prefer it when the web behaves deterministically

Wishful thinking methinks :)

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

> My questions is how to convert TIMESTAMP value to a Java Date
> or Calendar Object ?.....

It seems that the Timestamp here refers to the Unix timestamp (which is the number of seconds elapsed since January 1, 1970 (midnight UTC/GMT). This is in contrast with the way Java timestamp works which is considered to be the number of milliseconds elapsed since January 1, 1970 (midnight UTC/GMT). Multiplying the returned value with 1000 should do the trick here.

Also, ensure that you don't fall in the trap of truncation while multiplying those values.

Date d = new Date(1265207400 * 1000); //is different from
Date d = new Date(1265207400 * 1000L); // or
Date d = new Date(1265207400000);

In case you are still wondering why, in the first declaration the integer result of 1265207400 * 1000 which is 1966688416 and not 1265207400000 , is passed to the Date constructor leading to erroneous results.

> Thanks in Advance

HTH

zac_mathews commented: This was very usefull and very helpful... Thanks SOS +0
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

| has a special meaning when it comes to regular expressions, it's called the alternation symbol.

If you have something like "##|##|##".split("|") , it's the same as "##|##|##".split("") since a single pipe symbol is the same as saying "alternate between a blank string and another blank string" which is the same as a blank string.

You can either:

  • Escape this pipe character and tell the regex engine to treat is at a literal pipe character. Something like "string".split("\\|")
  • Use character classes, similar to the example posted above (i.e. [|] )
BestJewSinceJC commented: Haha! I knew that | = or, but couldn't recall it at the time. +4
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Would the try...catch work? The only way it will work is if it does synchronizing against all threads. Remember, the problem here is that 2 threads are calling the same check-create code, at the same time and 1's create may change the state in the middle of the other's check-create statement.

When you rely on gobbling exceptions + the correctness of the FTP library you are using, you need not bother with the 'check' phase. The code would be something like:

ftp.connect();
try {
    ftp.createDir("myDir");
} catch(DirAlreadyExistsException e) {
    // dir already exists, use it
}
ftp.changeDir("myDir");
ftp.storeFile("myFile", myFileIoStream);

This *should* work; if it doesn't, something is seriously broken.

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

You can try out the following things:

  • Place the folder creation code in the try...catch block and catch the specific FolderExistsException exception. When this exception is caught you know for sure that the target folder exists so you need not create it. You can just ignore this exception and continue with your work.
  • You can try the directory name to object mapping approach for locking as already suggested by James
  • You can have a workflow class as mentioned in one of my previous posts, but this time for your FXPThread classes. This way you can explicitly handle the dependencies.
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

folder is created then entered by one, then attempted to be created a 2nd time by the other, throwing a "already exists" error

If this is the case, then I think you are over-engineering the problem. A simple existence check for the directory is much more logical and simpler than trying to synchronize `n' FTP instances. Have you tried that out yet?

The only thing I can think of is to use a static object global to all FTPs to lock on, or to pass the same object to all of them, not per FXP, but for each FTP in general

Then you are basically making all your FTP actions/calls execute in sequence or only one FTP action at a given time. Your FXPing class uses FTP classes to do the real work. If you sync on a global static object and that too in your FTP class, it's as good as not using threading approach, at all.

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

IMO, the operations(mkdir & chdir) should be part of the same thread of execution. Also, creating a thread-aware Ftp class doesn't seem like a good idea unless of course you provide a provision to schedule multiple FTP actions synchronously.

I would have to create a generic static object and synchronize (the object), so only 1 thread is able to lock it at any time.

*Don't* use static variables for synchronization, at least not in your case. They seriously limit the way in which a class can be used and usually turn out to be scalability killers.

In your case, you need to ensure that both the FTP thread classes need to synchronize on a logical instance (and not a static variable). You can for e.g. create a FtpWorkflow class which would be passed to your Ftp thread class during creation. This workflow class can be used to share information between two Ftp operations along with providing a common ground for synchronizing the FTP operations involved in the workflow.

You can take this concept a bit ahead and expand on it by making FtpWorkFlow implement Runnable. This workflow class would now support scheduling of Ftp commands and make sure they are executed synchronously thereby hiding all the boiler-plate scheduling code.

You can of course use any XXX class for the same with a functionality of your choice though the basic idea remains the same.

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

Write String data to your DataOutputStream using the writeUTF method and read the same at the server using the readUTF method of the DataInputStream. Another option would be to write to the OutputStream by wrapping it in a PrintWriter and then at the client using the BufferedReader to read the same. Then:

  • Initialize a Map of String to Integer
  • Loop over the characters present in the String
  • For each character, check if it's a letter using the utility methods of the Character class
  • Check the presence of the character in the Map, if isn't not present, place the character in the Map with the value as 1 otherwise increment the value for the given character in the Map (you can apply the same logic using arrays if you need performance but I don't think you should concern yourself with these things right now)

Also, are you planning to use this code for a single client given that your TCPServer is stateful (since it remembers the previous string passed in)?

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

Whoa! dhanyavad!

You are welcome :)

No comprende.... If the page changes, I thought the cache would be overridden.

*Only* if the the server sends proper headers saying that the file XXX has changed; without that the browser has no way of knowing that something has changed. This is the very reason why Dani sometimes requests members to manually clear their caches after she rolls in a new version of library or images...

Database The page istelf was still the same. It was just the database contents that does not get stored in the cache that changed. Ja?

No, nothing related to database as such. From the looks of the screen-caps you posted, it seemed like a case of missing CSS(stylesheet) files.

As a rule of thumb, always CTRL + F5 when you see something unexpected; if it still persists, time to create a new thread. ;-)

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

Try pressing CTRL + F5

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

"Almost refuses to start up" is not so good a description. Have you analyzed your logs? Any stack traces/warnings? Are you deploying your application from eclipse or by firing off the shell script? <listener> is a standard tag and so ideally shouldn't any problems. Is the JAR with the class AxisHTTPSessionListener present in your WEB-INF/lib directory?

The only time I've seen applications break after updates is when they relied on libraries placed in the Tomcat lib directory rather than the WEB-INF/lib directory.

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

Also make sure that you override the hashCode method for your custom class to satisfy the hash code contract.

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

Think about what you've written for a while; do you really need two looping structures just to loop over a subset of a collection?

Given that Collection interface doesn't have a get method, the only option which remains is to keep an external counter which is incremented inside the iterator loop. This counter would keep track of the elements which need to be skipped (by comparing the counter value with the `index' passed in).

Oh and BTW, if this requirement is plain wrong/illogical. There is a reason why the Collection interface doesn't have a get method...

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

The problem is that you never use the `index' parameter in your overridden method. Also, you can avoid the cast by using the iterator as Iterator<? extends E> .

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

Hint: c.iterator() creates a new Iterator instance.

Also, calling next() on an Iterator without testing the presence of an element using hasNext() is not recommended.

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

> what about the Jcreator compare to the eclipse which is prettier?

I've never heard of/used JCreator so can't really comment on that.

> i have downloaded the eclipse but i dont know how to use it ...

Read the online documentation for Eclipse; search terms like "eclipse beginner tutorial" might help.

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

Initialize allData or allDccs (I guess there is some sort of mix-up here) in the while loop and you should be good to go without having to clear the list.

Anyways, to clarify up the matter, there is only one list in your case which is pointed to or referred by two different references. So when you say you clear one of those lists, you are actually using one of those references to clear the only list you have and hence it is giving you issues.

KirkPatrick commented: Thank you for the help and explanation of why it was going wrong. It helps to understand how/why code isn't working the way I intended it to. Cheers bud +1
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> please suggest me if what is the best compiler for java?

The JDK provided by Sun along with Eclipse as an IDE works out pretty well for me.

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

Yes, given that you can't spawn multiple instances, it's kinda difficult to get your requirement to work. Anyways, as a last resort, you can always try out the Tomcat user forum.

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

> is there any way around if I can pass all corresponding values
> (itemName, itemLocation, status) for SELECTED checkbox

That would be a flawed approach since the client can easily intercept the request and inject spurious data in it corresponding to your item ID. I've always followed the rule of thumb to *not* pass something which can be retrived by your business layer. The risk involved in sending the data from the client is far more than the performance implications of calling the query again. BTW, if you are implementing a kind of item processing system, why not just work with ITEM ID's instead of dealing with all the details again?

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

> if I check few checkboxes and on clicking submit how to pass each
> row data values

Read the replies posted by me and Peter again...

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

> Should I use simple ArrayList or HashMap as I need to pass selected
> checkbox values...

Just ensure that all your checkbox elements have the same name and then use the HttpServletRequest.getParamterValues('elementName') to retrieve a String array containing the list of item id's.

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

> I tried manipulating the blob datatype by setting..

The way you are going about to do this won't work. You can't render an image on your markup without using the IMG tag just by grabbing the binary content. You'd need to create a separate servlet mapping which would read the contents of the image from the database and write it out to the servlet output stream. You'd then use it like:

<img src="/yourWebApp/yourServletPath/grabImage?id=yourImgName" />
public class MyController extends HttpServlet {
  public void doGet(HttpServletRequest req, HttpServletResponse res) {
    // check if the path contains 'grabImage'
    String id = request.getParameter("id");
    // read the binary content using the code present in your JSP
    byte[] data = readImage();
    response.getOutputStream().write(data);
    // perform misc cleanup
  }
}

> assuming i want the size of that image to be width=200,height=200 on
> display,how do i achieve this

Use some image manipulation library to do the same. Google if your friend.

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

> We just can't have personal instances of the application in our individual
> computers because we only have one license

One license of what? Is it something which your application refers to which can't be deployed on different machines? Maybe explaining things in more depth might help us give more relevant solutions.

Anyways, how about spawning different Tomcat processes for each developer? Given that you only have a single development machine, I'm sure it'd be good enough to handle that kind of load.

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

The action /Login should be /YourWebAppName/Login .

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

It seems as though placing a taglib declaration triggers some kind of taglib validation in action which blows up when it encounters a problem. Does this problem come with only the above mentioned JSP or does it happen with all the JSP's? If it happens only for the above mentioned JSP, you might have to run it through a sanitizer script which strips all the characters unacceptable by the XML specification. You can try this link for the same.

You can get the latest JSTL API + implementation here.

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

IMO, the error is exactly what the trace says it is; it has found an illegal non-visual character in your markup.

Are you sure the error comes *only* when you put the taglib include and works otherwise? If yes, then instead of copy-pasting that line try typing it out. BTW, you are using an old version of JSTL; the uri should be http://java.sun.com/jsp/jstl/core .

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

This can be due to a lot of factors:
- Web application was not properly deployed i.e deploy time failure
- Attempt to access a path/resource which doesn't exist

Without more details like the name of your web application, the URL you are trying to access, your deployment descriptor etc. it would be kinda difficult to pin point the exact reason behind this.

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

> How would you recommend me doing this? Should I write the entire
> game from the ground up? Should I use a game engine?

Start small and definitely go for a game engine; you are trying to write a game and not a game engine. Leave the exercise of writing a game engine to a some other time. How about developing your game using Slick 2D Engineand then serving it via Java Web Start. Never done that but should be a fun exercise.

> Java applets?

AFAIK, Applets come with their own headaches and are generally frowned upon by end users due to their startup time. See my suggestion above for alternatives.

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

> but I'm still curious to know if there is a way, just in case I face this
> problem again

You can make your code work by passing in a list reference which already points to an existing List implementation. That way, even though you have a copy of the reference, it would in the end point to the same list which was passed. You'd need to change your Object de-serialization part of code to do an addAll() on the list passed by passing in the List read i.e.

if (prototype instanceof ArrayList) {
  list.addAll((ArrayList <Classe_Pessoa>)prototype);
}

You might want to add in a few null checks there though but yeah, that's how it can be done.

That being said, I'm still in favour of the method responsible for returning the data read in an appropriate container rather than the caller passing in a empty container to be filled by the method since your method puts undue responsibilities on the caller, something it isn't responsible for.

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

This is because you effectively pass a copy of reference and not the list when invoking the method. Read this.

Crushyerbones commented: Very interesting +2