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

Are you using a redirect on the server side when serving the excel file? How exactly is the download feature implemented? Also, what's the code you are using to download the excel file?

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

OK, so basically anything which would be broken for a couple of hours or so would be by choice and not bad luck? ;-)

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

Why the reluctance to create more forums, does having more forums affect something that we aren't aware of?

At least from a moderation viewpoint, it amounts to more house keeping which needs to be taken care of. Plus, it's not like it was always this way in the past. Forums *were* created based on user request. But it turns out that the forum is created, it receives little or no activity and becomes target for link spam which might go on unnoticed for a long time.

Another point is having expertise in a given area. Most of the times it turns out that a new forum is created, the member who requested the forum creation actively answers questions on that forum and suddenly disappears. This results in the forum being filled with regulars who are seeking help rather than someone who is capable of resolving them. I know it has to start *somewhere* and it is worth a try but our previous experience has been pretty bad with this stuff.

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

Ah! I found the reason for this error, atlast!
This is a snippet out of a ebook I downloaded:

Well, I did explain the same thing in my previous post:

Anyways, AFAIK, relative paths are a problem because they depend on the current context i.e. a page served using the URL `http://localhost/app/jsp/first.jsp` would have a different context (and hence the notion of "current directory/path") from the one served using `http://localhost/app/someservlet`. To test this out, change the 'forward' to 'redirect' and the images should again show up on the page.

what would my full server path be?

Assuming your application root is: http://localhost/ContactKeeper, the image path should be /ContactKeeper/Images otherwise if your application is the default application deployed (i.e. accessed using http://localhost), then /Images should do the job.

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

Did you force a refresh (CTRL + R or F5)? Are you still getting the same results after that?

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

Looking good, nice job!

BTW, just noticed that this isn't applicable when I click on a particular forum (e.g. Java from the drop-down). Not sure if this is how it was meant to be. Same with permalinks for thread posts (the PERMALINK link). Also, I think it would be wise for everyone to force a refresh (CTRL + R) since I was getting weird issues without it.

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

> The code does not change at all no

When I mentioned page source, I was actually talking about the generated HTML source. If you inspect the generated HTML, you should be able to find out *why* the images are not rendered based on the path used.

Anyways, AFAIK, relative paths are a problem because they depend on the current context i.e. a page served using the URL `http://localhost/app/jsp/first.jsp` would have a different context (and hence the notion of "current directory/path") from the one served using `http://localhost/app/someservlet`. To test this out, change the 'forward' to 'redirect' and the images should again show up on the page.

Almost all real world websites use "absolute" paths for providing image sources of the form <img src="${IMG_ROOT}/daiblo.jpg" /> where IMG_ROOT holds the location of the image source. It can be either located on the same server (i.e. IMG_ROOT=/images) or be a completely different site (IMG_ROOT=http://flickr.com/dean/images).

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

I personally don't like placing the image writing code in the PhotoFile class. Plus, you should not write raw bytes but the PhotoFile object to the ObjectOutputStream. The algorithm for writing should be:

  • Start the main method by looping over the image files
  • Create a new ObjectOutputStream instance outside the loop
  • For each image file, read the file details (name, format and bytes)
  • Create a new PhotoFile object based on the above details
  • write the PhotoFile instance to the OOS (object output stream) object

For reading:

  • Open the ObjectInputStream using the .ser file you just created
  • Keep on invoking readObject() method and reading in PhotoImage objects as long as an exception is not thrown (there are better ways of doing this, but do this for the time being)
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Not that I know of; on the contrary, PreparedStatements are capable of being compiled down to an efficient representation since the structure of the query remains the same with the variables being parametrized. This is much better than creating a SQL query for each request by concatenating the values of x and y to the original SELECT query which can't be compiled down to an optimized form.

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

It does not matter whether x and y are from the user or not. You can set it in the prepared statement as you do it for username and password. As long as 'x' and 'y' are variables which are available in the scope of the method, you can use them as you would use your username and password.

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

If you need to pass them for every call to prepared statement, then they are not constant and should be part of prepare statement. If they really are constants, you can embed those values in the query itself. Or you can combine both the approaches:

var pStmt = "select * from tbl where u=? and p=? and x=? and y=?";
pStmt.setString(1, user); pStmt.setString(2, pwd);
pStmt.setString(3, CONST1); pStmt.setString(4, CONST2);
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Rename the class to something more logical rather than naming it Serialize. Ensure that your class has a serialVersionUID field (google for it). Also, no need to make name and format as a byte array, let them be strings. As far as writing images to ser file is concerned:

  • Create a file object from the image path
  • Create a new Image (your class) object and set the name (retrieve from file object), format (png, jpg) and bytes (google for reading bytes from a file).
  • Create an ObjectOutputStream and use the writeObject method of this stream to write your Image objects
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Three ways I can think of:

  • Read the image as a normal file, extract the bytes from that file and write the given byte array to the ObjectOutputStream. This is the quick and dirty way of doing it but you won't have the image details (the image name, format etc.) since you are writing out raw bytes
  • Create a custom image class having a byte array field, name and format field, make that class implement Serializable and write the object of that class.
  • Use the ImageIO clas for read the file as a BufferedImage and write the image to the ObjectOutputStream using the write() method of ImageIO. Roundabout way and not recommended.

I would personally go with the second method.

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

I *think* I do understand what kind of problem Chris *might* facing here. I am for some reason getting the same result when I first click on Unanswered Threads and Todays posts after that. The result is the same page which I see when I had first clicked Unanswered threads. But for some reason this went away after I pressed CTRL + R in Opera. Have you tried that Chris?

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

You can't since the signature of the run() method is fixed. The way you are doing it suggests you have some custom task which needs to be executed. In that case I would recommend creating a custom Runnable or Thread class which takes those two "strings" as constructor arguments and use them when the "run()" method is invoked.

class WorkItem implements Runnable {

  // declarations

  public WorkItem(final String one, final String two) {
      this.one = one;
      this.two = two;
  }

  @Override
  public void run() {
      // process strings one and two
  }

}

Just pass this Runnable instance to a Thread object and you should be good to go. If there are multiple such work items, a better suggestion would be to use the new utilities provided by the java.util.concurrent package, namely ExecutorService.

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

Have you tried inspecting the page source in both the cases? Do you see a difference in the image paths? Are you using relative or absolute path location for loading your images?

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

A serialized image written to a file is not the same as an image written to a file. Java serialization uses a specific binary format for writing out Java objects. Also, your post isn't clear. What exactly does "serialize[x]" contains i.e. what kind of object? What is locaties?

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

Generally, you don't want to write code this way - exceptions should handle exceptional conditions, not expected ones - but that's the way the Integer class is written.

I know that, but if the API exposed by the core library says that parsing an invalid input for integer results in an exception, that's how the client should handle it rather than trying to find ways to get around this fact, unless there is a good reason to believe that a custom implementation would make much more sense than the de-facto approach.

If you want to learn something more about why this is, do some reading about exception handling. A little quality time with google should see you sorted on this.

Not sure if this was intended for me or the OP but if it's for me, I think I've done a good amount of reading and am aware of *when* and *how* exceptions should be used. :-)

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

Try to parse the user input as a number; if it fails, the given string is not a valid number, otherwise it is. Look into the parseXXX method of the wrapper classes (Integer, Long, Float etc.).

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

Then browse through your anti-virus documentation and have a look at how you can unblock the glassfish application server.

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

First, don't mess with your Tomcat lib directory; all application related jars should ideally go in the WEB-INF/lib directory of your web application, unless you have a good reason to not do so.

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

Was it working fine previously or is this a new install? If this is a new install which version? Also, AFAIK, Glassfish had problems starting up if the install path contained space characters (as it is in your case).

If a reinstall doesn't fix it, I'd recommend hitting the Glassfish forums for better answers.

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

> all the suggestions will be greatly appreciated!!

Assuming the normal quadrant and angle measuring convention:

x = cx + r * cos(theta)
y = cy + r * sin(theta)

where:
x, y = coordinates of the point on the circumference of the circle
cx, cy = coordinates of the center of the circle
r = radius
theta = angle in "radians"

After you get (x, y), it's just a matter of drawing a line from the center to (x, y) and you should be good to go. Of course, this would work assuming you convert the angle values from degree to radians and adjust the adjust the read angle values based on how your accelerometer is oriented.

Good read: http://www.yaldex.com/games-programming/0672323699_ch08lev1sec4.html

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

Regarding the error message, I think what is happening here is that when you are logged in successfully, you are assigned a session token (which looks like the output of a hash algorithm like MD5 or SHA etc.) which has a fixed validity. Given that you were trying to use the same token in the morning (a token which was generated sometime in night), the token validity check must have failed on the server resulting in the given error message.

But this still leaves us with the question as to why the original post wasn't successful which I think Dani might be a better position to answer.

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

OK, since CTRL + R seems to fix this, it seems more like a issue with HTTP headers. The suspicious one is the "Expires" header which is pointing to a future date for this page request...

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

OK, just to help out others who are facing the issue, a force refresh for some reason is fixing things on my end, at least temporarily. E.g. if you want to view the latest CP, visit the CP link and press "CTRL + R" or "CTRL + F5" (force refresh, at least in Firefox).

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

Hi Dani,

For some reason, I'm always getting the cached or old version of a given page. E.g. clicking on the CP link shows me a thread which was recently bumped in the C++ forum. After I added code tags to the post and moved it to a separate thread, I'm still getting the same notification in my CP in the subscribed thread list div box.

Can you look into this? Anyone else facing the same issue?

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

When reading from a file, always check for "hasNextLine()" before calling "nextLine()" method. Also, your method calls "object.setIsPrime()" and the line reading part "nextLine()" should come in a loop which will continue as long as there is a line that can be read. Also, your implementation of prime number checker seems to be off. Read the wikipedia article or many other articles around the internet on the subject matter and try again.

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

OK, sounds good, let's see.

Oh, and BTW, the quoting of noparse tags is kinda weird i.e. if you click "post reply" button for your very first post, the noparse tags are stripped off, leaving only [quote] tags. Not sure if this is expected behaviour...

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

One suggestion: I personally think that a single line is kinda insufficient for establishing the context. I agree that the *entire* quote appearing in a post esp if the quote is large requires a lot of scrolling, but 2-3 lines shouldn't be much of a bother. Plus what happens if the post to be quoted has a single line? Is there a way of knowing this?

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

I've made a change to the way that quote tags are implemented. As you remember:

[quote] by itself will always show the full quote
[quote=.....] will show/hide the quote, to eliminate redundancy and having to scroll past huge quotes

Now, when you are using the quote tags that show/hide the quote, the first line of the quote always shows up. This gives you a sneak peek to refresh your memory what the quote is, and which line of the person has been quoted, without the whole drawn out message all over again.

Looks like a good change, esp for large quoted text; thanks.

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

Your Stack implementation is not generic i.e. doesn't accept type parameters. Or is it that you are planning on using the Stack implementation provided by the standard library?

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

Why are you using DataOutputStream for writing out textual content? Use PrintWriter by passing in the FileOutputStream created, invoke its println() method and you should be good to go.

Always make sure that you use XxxWriter for writing out textual content rather than streams.

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

now i am having this problem with evaluating the postfix

*What* kind of problem? You need to be more detailed when posting problem statements rather than just saying you've got a problem.

BTW, the code isn't pretty as far as error checking is concerned. You only test for the first character of a token to verify its correctness. As per your logic, the following postfix expression becomes correct: 1 2 +? and yields 3 but it shouldn't. Similarly, the expression 1b 2 + fails in an unexpected manner.

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

The simplest solution would be to write out a new file with the updated data and delete the original one. A sample implementation to get you started would be: http://www.javadb.com/remove-a-line-from-a-text-file (untested)

A really messed up solution would be to try to get something working with RandomAccessFile but then again it would blow up for variable length substitutions.

The create a new file solution works pretty well for *most* of the cases. If you get the feeling that this solution is turning out to be unwieldy due to performance reasons, move to an in-memory database.

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

You have not initialized your operand stack and you don't do anything with the value returned by the "evaluate" method.

That being said, don't use StringTokenizer but use the "split" method of the String class. Also, Stack class extends Vector class which has all its method synchronized and has fallen out of use except in legacy cases. If you are using Java 6, use a LinkedList class or ArrayDeque class exposed by the Dequeue interface.

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

Let say I click on a link on this page, for example, your user name, but instead of opening another html page such as your profile, it runs an application.

Run an application where? On the server or on the client PC (i.e. a user accessing your application). In case it is the later, it can't be done in a standard way, for security reasons. If you are OK with targeting a specific browser/OS environment, I think this can be done with custom browser addons but I'm not aware of any of those.

These applications I downloaded of the internet and now need to install on the Tomcat

What are these *applications* you speak of? Tomcat is a servlet container and can be used to deploy "WAR" files. Not sure what this application is which you want to deploy on Tomcat.

If your aim here is to open up installed applications on user's computer, you'd be better off with a desktop application, rather than a web application. Is this a client requirement or something you need to do just for fun?

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

Of all the posts in this thread, I am in complete agreement with Progr4mmer's post.

To someone beginning programming (not just Java), I'd neither recommend a full-blown IDE or a stupid text editor like Notepad. I mean come on, if you want to test your vision, there are better things to do that "try" to program in Notepad. :-)

I wouldn't recommend a specific text editor but any editor which does smart indentation, syntax highlighting, has the option of converting tabs to spaces, a regex based search/replace and multiple encoding support is worth its weight in gold.

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

BTW, I just compared the result of the query "starting java" using a US proxy and my own connection and for strange reason, the thread started by me ranks above the official Java tutorial. :-P

with proxy (US proxy):

without proxy (India servers):

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

The way I see it, Google has now decided to rank content creators/sources higher than content consumers and the content creators are now judged based on visits, track-backs, how long the visitors stay on a given site (certainly possible) and the discussion surrounding that given site.

This might be the reason why search for terms like "time complexity of algorithm" would definitely put Wikipedia and other free online book links at a higher priority than forum links. It's also a possibility that this algorithm puts *all* the discussion boards at a disadvantage assuming that they would be mostly content consumers and not creators. I think the track-backs also play a big role here. If a "time complexity of algorithm" search brings up two articles: one from Daniweb and one from site XXX, and if the link from site XXX was discussed on hacker news or reddit, it would be placed before the Daniweb one. Or so I think... ;-)

But I'm surprised that you are surprised at a Wikipedia link ranking higher than Daniweb. :-)

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

> You realize I was joking, right?

You realize that given your position/designation on this site, you can be easily quoted out of context, right? :-)

Anyways, on the topic of improved content, I do see a reduction in the "plz gimme codez and projectz", more first timers using code tags and a lot of new faces to keep the forum alive in case the old-timers decide to ditch it i.e. looking good from a beginner forum view point. What I feel is actually lacking is "good" non-student questions and members who can answer those. It still feels as though 99% of the site members consists of students/aspiring programmers and only 1% who actually earn their bread/butter by programming, but then again I'm sure you are aware of this. Not saying that there isn't anyone who can answer those, just that such niche questions normally drop off the radar of members for reasons unknown.

I'd be more interested in hearing the views of non-moderating staff contributing members since they are the ones who spend the most time in the respective forums.

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

As I suspected, you are running out of heap space. When spawning the JVM process, pass in the following switch as JVM argument: -Xms128m -Xmx128m .

If you are invoking the java process from the command line, you can use:

java -Xms128m -Xmx128m pkg.MainClass

If you are using an IDE like Netbeans or Eclipse, refer the relevant documentation (i.e. google for "set heap size netbeans/eclipse").

Another variant of this exception is when you run out of permgen (permanent generation) space. Read this article for more details.

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

What kind of problems are you running into? If you can read a couple of lines, you can read 95K lines...

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

Take a look at the SQL insert syntax and compare it with yours. Do you see anything wrong with it?

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

OK, here we go.

Thread_1 outputs values from 1 to 1000. Thread_1 waits. Thread_2 outputs values from 1 to 1000. Thread_2 now waits. Thread_1 outputs values from 1000 to 2000. Thread_1 is done. Thread_2 outputs values from 1000 to 2000. Thread_1 exits followed by Thread_2.

I'm not really convinced with the scenario you have presented since it can easily be solved by a single thread, esp given your requirement that while thread1 is counting, thread 2 shouldn't do anything. The answer I'm presenting here is assuming that you have a valid scenario which justifies this approach i.e. thread 1 does task A which thread 2 depends on (task B), thread 2 does task B which thread 1 depends on (task C), thread 1 does task C on which thread 2 depends (task D). Maybe if you posted the real requirement I might try to help you with an even better solution.

One way of doing this would be to use a SynchronousQueue as a sequencer here. The unique thing about this queue is that its "put" and "take" operations for an item block as long as there is nothing on the other side (i.e. another task aka thread) to "take" or "put" the item respectively.

The way we use this class is pass it to the two work unit classes which we have (worker 1 and 2) and ensure that the sequencing is orchestrated between them using this queue. Here when I say worker 1, I mean …

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

Ideally the JAR files in the WEB-INF/lib folder should show up in your Java Build Path -> Libraries tab -> Web App Libraries ? Don't you see your JAR files there?

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

Create a new variable guess count which keeps track of the number of times the user guesses the bean count.

do {
  if(reply == jellyCount) {
    // break and congratulate user
  } else {
    // increment "guessCount" and show the failure msg to user
  }
} while(true);
// since we have while(true) make sure you provide the user an option
// to quit in between the "game"
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Is it necessary for you to write your own lock implementation for this or are you free to use any standard classes for the same?

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

URLConnection class should help you get started. Post your code if you are still facing problems.

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

I was talking of writing a test method along the lines of:

public void testLeaf() {
  BinaryTree t = new BinaryTree();
  t.leaf();  // prints nothing

  t = new BinaryTree();
  t.add(100);
  t.leaf();  // prints 100

  t = new BinaryTree();
  t.add(1); t.add(2); t.add(3); t.add(4);
  t.leaf();  // prints 4

  t = new BinaryTree();
  t.add(4); t.add(3); t.add(2); t.add(1);
  t.leaf();  // prints 1
}