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

> Did not solve the problem

You sure? The same piece of code works for me. BTW, what kind of process is writing to this file of yours? Another Java process? Which JDK version are you using? I used Notepad to update the file & the updates were reflected in my case.

~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

NumberFormat is an abstract class; use its static factory method to get your choice of number formatter.

public class MainTest {
   
   public static void main(String args[]) throws Exception {
      // Get a number formatter for the default locale
      NumberFormat nf = NumberFormat.getNumberInstance();
      nf.setMinimumFractionDigits(2);
      System.out.println(nf.format(1.1));
      
      // Get a number formatter for a different locale e.g. french
      nf = NumberFormat.getNumberInstance(Locale.FRENCH);
      nf.setMinimumFractionDigits(2);
      System.out.println(nf.format(1.1));
   }
   
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Try using the RandomAccessFile in read mode.

public class MainTest {
   
   public static void main(String args[]) throws Exception {
      RandomAccessFile in = new RandomAccessFile("file.txt", "r");
      String line;
      while(true) {
         if((line = in.readLine()) != null) {
            System.out.println(line);
         } else {
            Thread.sleep(2000); // poll the file every 2 seconds
         }
      }
   }
   
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

...because there is always more than one solution & more than one way to do things. Technical discussion never die out and there is always room for contributions; though I must agree this involves a bit more housekeeping effort on part of the moderators.

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

The commas and the brackets are a part of the ArrayList class's toString() implementation. If you need your own row representation, either write your own method which does so or better yet, create a custom class called BoggleRow which uses composition or inheritance to mimic the ArrayList class. Something like:

public class TestRun3 {
    // your code here

    public void displayRow(List row) {
        // code which loops over the list & displays the row
    }
}

//OR

public class BoggleRow {
    private List row;
    public BoggleRow() {
        row = new ArrayList();
    }

    @Override
    public String toString() {
        // your code here
    }
}

// OR

public class BoggleRow extends ArrayList {
    
    public BoggleRow() {
        super();
    }

    @Override
    public String toString() {
        // your code here
    }
}

The above code gives you a rough sketch of how your class would look like. My personal preference would be the second implementation.

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

> So some kind of loop is needed

...which is what I have in my previous reply. Re-read my previous reply and try implementing that with the code you currently have. Just make sure you put all those JCrypt related statements *inside* the loop since you need it to be done for each original & salt string.

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

Use getValues().nextLine().equals("n") instead. The Scanner name is confusing BTW, just name it scanner instead of getValues which is more appropriate for a method name.

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

You are comparing a Scanner object with a String object.

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

The problem is with this line firstcube = static double pow(double first, double 3); which is invalid. When invoking methods, you don't need to specify the method modifiers along with their parameter types. I'd recommend reading the Java tutorial on Sun or the sticky at the top of this forum to get started with Java.

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

What is the name of your web application? If it's school, then trying removing /school from the URL pattern. It should work. Also, specify the location of all your resources wrt the web app root i.e. exclude the `school' directory.

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

Anything placed in the JSP between the <%! %> tags [jsp declaration tag] is placed outside the service() method but inside the auto-generated servlet class. You can of course create a method containing the given piece of code, which can be invoked from within the code placed inside the <% %> [scriptlet tags]

The bottom line is that anything placed in the JSP declaration section forms part of the auto-generated servlet [and is *not* executed] whereas anything placed between the JSP scriptlet tags is executed for every request received by that JSP. In your case, you might want to declare a method in the declaration section and invoke the same from a scriptlet.
.

<%!
private static void invokeSomething() {
    // your stuff here
}
%>

<%
invokeSomething();
%>

Oh, and in case you didn't know, placing logic in JSP's and using scriptlets is bad and has been deprecated since times unknown.

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

This doesn't seem to be a JSTL problem since the class missing belongs to the jsp-api.jar library which is a part of the standard distribution [i.e. part of the specification, placed in Tomcat/lib]. Have you tried making your application work outside Netbeans by copy-pasting the WAR file in the Tomcat directory?

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

Oh and BTW, once you are done with understanding how web services work, try splitting your logic in layers like the business[model] layer, database[persistence] layer etc. Database access from a web method is err... bad. :)

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

Assuming both the files have the same number of lines i.e. a salt for each string, you need to keep reading the data from your readers till the readLine() method returns null . Something like:

while((original= readerOne.readLine()) != null &&
             (salt = readerTwo.readLine()) != null) {
    JCrypt.crypt(salt, original);
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

No, you are not going stupid. :)

I guess I've stumbled upon something. Let's search for the post highlighted in your screen caps [click the first search result]. Now if I click on toggle plain text, I don't see any <strong> tags.

Now let's search for another code snippet & click on the first search result. Here, clicking the toggle plain text link again brings up those HTML tags.

Also another weird thing is that the problem is more prominent with C++ code snippets than with Java code snippets [try searching for "daniweb scanf c" & "daniweb println java"]. Gah, I think trying to make sense of this is like a lost cause, just click on the 'Clear' link which appears at the top of every thread when you arrive at Daniweb from a google search and be done with things.

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

This issue was brought up & discussed to some lengths a couple of months back.

> As you can see I have no tags whatsoever in "plaintext"

This problem crops up only when you arrive at Daniweb via a search made on google; all the highlighted terms [in yellow] in the source code show these weird tags when viewed in plain text.

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

> Thought this was a feedback forum. If moderators/admins don't like
> honest feedback, why not have a "Daniweb Community Feedback" for
> ****-lickers only.

Keep things on topic; there is absolutely no need to throw around verbal filth and make irrelevant generalizations about mods and admins.

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

> i miss getting beat up by her.

You can of course pop in the Daniweb irc to get beaten down in real time... ;-)

peter_budo commented: Lottery winner for sure +0
jasimp commented: haha, I don't dare enter that cave +0
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> If re-direction must occur, it must be the first line of a constructor. Why?

To ensure that the parent class is completely initialized before it gets used in the child class's constructor body. If this restriction was not imposed, you could have code like this which really doesn't make sense:

public class A {}
public class B {
  public B() {
    // How do you expect to access something before it is contructed?
    Class c = super.getClass();
    super();
  }
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

*sigh* Some people never learn....

Closed.

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

Remove the semi-colon from your JSP expression.

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

Hmm...this is a problem indeed. I've found that checking the 'Remember Me' checkbox fixes the problem, at least on my side.

@Dani
For some reason, the bbsessionhash cookie is set only if the 'Remember Me' check box is checked; you might want to look into this.

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

What's wrong with the getTime() method of the Date class which returns the number of milliseconds elapsed since January 1970 as long? To get the seconds, just divide by 1000.

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

> How could a firewall cause the problem? both computers are using the
> same firewall.

Probably a configuration issue. You might want to try turning off the firewall for a couple of minutes and then see if you can observe the same behavior.

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

> Why is it that even when i specify the index to go to it still returns -1 ?

It's not returning -1; the exception says that you can specifying an array index [-1 in your case] which is out of bounds for the given array [either less than 0 or more than equal to the array length]. Try debugging your application to determine the exact cause of this exception.

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

Most probably your browser is not set to accept cookies from Daniweb which is the mechanism used for session tracking. This might be because of the Firefox add-on you use or a firewall running on your computer.

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

> is it possible to loop through the contents of two arrays to populate a
> third array with the combined content?

In my code I'm using looping through two Lists and populating a third list which is then converted to an array and returned.

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

Sadly, this simple a thing becomes pretty clunky to implement when it comes to Java. A sample implementation might be something like:

class YourClass {
   
   private static final List<String> LOWER_CASE_CHARS;
   
   private static final List<String> UPPER_CASE_CHARS;
   
   static {
      LOWER_CASE_CHARS = listFromArray("abcdefgh".toCharArray());
      UPPER_CASE_CHARS = listFromArray("ABCDEFGH".toCharArray());
   }
   
   private static List<String> listFromArray(char[] charArray) {
      List<String> list = new ArrayList<String>(charArray.length);
      for(char ch : charArray) {
         list.add(String.valueOf(ch));
      }
      return list;
   }
   
   public String[] fillResultArray() {
      boolean checkBoxOneChecked = true, checkBoxTwoChecked = true;
      List<String> stringList = new ArrayList<String>();
      if(checkBoxOneChecked) {
         stringList.addAll(LOWER_CASE_CHARS);
      }
      if(checkBoxTwoChecked) {
         stringList.addAll(UPPER_CASE_CHARS);
      }
      return stringList.toArray(new String[] {});
   }
   
}

Does that work out for you?

cwarn23 commented: great code snippet... +4
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

After reading the FAQ, the two features which I found interesting were:
- No type hierarchy; this is a life safer given that the ridiculous amount of time OO programmers spend juggling with type hierarchies.
- Goroutines instead of threads; spawning a new thread only when it's absolutely required is cool IMO.

That being said, the syntax looks a bit ugly and convoluted.

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

I want to implement this technique in an Inventory software where ,when a user buys e.g Ford Mustang the units sold shall be decremented from 1000 which is the total available units in stock.

You'd typically look-up the item of interest and then perform the necessary operations on it rather than setting a particular item of the ArrayList. A better implementation here would be have your own Inventory class which provides another layer of abstraction over the List implementation of your inventory and then have methods like lookup(itemId) or find(itemId) to find a given item. After it, all that needs to be done is modify the quantity property of that item.

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

> Does anybody know how I can append to the array

You can't. The best you can do is perform a copy-on-write if the content to be written is more than the initial capacity with which the array was created. Try using an implementation like ArrayList which relieves you of all this resizing business. Is there any specific requirement you are trying to fulfill which can't utilize better data structures?

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

AFAICT, Dani uses a customized version of vBulletin so any feature which isn't supported out-of-the-box has to be patched in. BTW, why do you need this feature? I mean, how different is it from going to your own profile and viewing the solved threads in each forum.

IMO, the chances of anyone using the suggested feature is pretty rare.

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

> Should poster who answers a question only be a qualified MSCE?

Definitely not; a question posted on Daniweb is always open to discussion. Personal attacks as a means of adding more value to the discussion or correcting an existing incorrect [supposedly incorrect?] answer is not acceptable as per the forum rules and falls under the 'Keep it pleasant' category.

Can you report those posts by pressing the "Flag Bad Post" link so that the same can be discussed in the moderators' forum?

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

> Is there something similar to this that I can use for a Java Web App?

Yes, you can either use the <jsp:include> standard action or tag files to include reusable view templates in your web pages.

Edit: Just keep in mind that the above mentioned techniques include the content at runtime. If you are pretty sure that your re-usable views would never host dynamic content, go with the include directive which includes the content at translation time as opposed to run-time.

kvprajapati commented: Good suggestion. +6
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> The following program doesn't work in my Linux system's Mozilla firefox.
> Any help to fix this problem is appreciated

This isn't a browser problem. Make sure that your page which hosts EL snippets has an extension of .jsp and not .html . The container serves HTML pages as static content instead of running them through the entire JSP life-cycle [translate-> compile -> load -> instantiate].

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

> Also, you're missing the point that if even a handful of people did use
> the feature every five seconds, the database would most likely end up
> very overstressed

That's why I mentioned "This should take care of the scripted attack issue". If you are having database performance issues, the current system is good to go.

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

>It preserves your formatting and uses a terminal font:

...but is still not enough since the original CODE tags didn't add line numbers. This auto-line numbering feature kinda breaks posts in which code tags were used for the sole purpose of preserving formatting and using a terminal font *without* the line numbers. E.g.

1. Wake up early
2. Brush your teeth
3. Take a bath
4. Off to work, which kinda sucks

I'd recommend the people who miss the old code tags to use [code=plain] [/code].

1. Wake up early
2. Brush your teeth
3. Take a bath
4. Off to work, which kinda sucks
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> there's no way of knowing for sure whether or not it's automated.
> Someone could set up a greasemonkey script, couldn't they?

I'd again like to suggest what I initially suggested for the "Tags" feature. Instead of having a blanket rule applicable to all, the time duration should be configurable. E.g. Newly registered/those with less than 50 posts/those with less than 30 rep would need to wait for 15 seconds but the duration would be relaxed for those who satisfy the criteria to let's say 5 seconds? This should take care of the scripted attack issue.

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

> What i want to do is to search the string

Depends on what kind of search it is; if it's just searching for a single character or a string you can use the overloaded versions of the indexOf method. If you need power searching i.e. search for digits only or search for a pattern which starts with a ! and ends with #, you need to use Regular Expressions, which I admit might take a bit of learning.

> So if someone fills in "abc" in my 3 digit html form, i want the string to
> return null

You are now talking about validation which is a specific application of string searching. You can use regular expressions for such purpose. But IMO you'd be better off using a validation library like Commons Validator which would relieve you of writing all the validation code yourself. But this again comes with a bit of learning curve.

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

You say that the form sends an empty string but your error checker doesn't detect empty strings? Have you tried debugging your code to see what *actually* the error checker is checking against?

There are a number of ways in which the problem can be rectified but without knowing the actual business context, suggesting an appropriate solution might be a bit difficult. How are you actually sending that value to the server? Setting it using Javascript? Sending it via hidden variables? Is that value mandatory i.e. should that value always be a digit?

As far as the solution is considered, there are a couple of them:
- If a check for blank string fails it means that the value sent consists of spaces. Try trimming the string before checking it for blank.
- You can always catch the NumberFormatException which is thrown when parsing the fails thereby handling all invalid input.

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

> Thank you - my understanding of generic types is still somewhat limited.

When in doubt, always look at the standard library code which comes prepackaged with the JDK. For e.g. in this case, looking at the source of the ArrayList.java file would have solved your problem. :-)

Ezzaral commented: Good suggestion which is often completely overlooked. +9
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Maybe the use of <E> in the iterator class is taken as a new declaration of a type, and masks the <E> that is declared for the outer class? If so, maybe you could declare the iterator class as
public class CircularListIterator<F extends E> ...

IMO, though the analysis is correct, the solution provided isn't because an Iterator over a collection of elements of type E isn't the same as an Iterator over a collection of elements of type F which extends E. The solution here is to declare CircularListIterator like:

private final class CircularIterator implements Iterator<E> {
  // methods go here
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Could that why the created it as an object?

There is absolutely no valid reason as to why a Boolean object needs to be created if one already exists and is ready to use i.e. considering that a Boolean can have only two states: TRUE and FALSE and those two are already accounted by the public static fields TRUE and FALSE of the Boolean class.

> Traditinally, there is no such thing as a native "boolean" type.

There is a primitive type "boolean". The usage of the primitive wrapper type Boolean v/s the primitive type boolean boils down to the use case in consideration i.e. whether you have an array of primitives or an array of reference types.

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

Hmmm...insanely strange. If you are talking about the 'Flag Bad Post' link, see it in the attached screeny.

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

[edit]

It's not a snippet anymore, now I can also see both links. But see this snippet for example. I can flag comments, but not the snippet.

Have you tried clearing your cache? Because I can see the 'Flag Bad post' link...

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

I can see both the links. Try clearing the cache using a force refresh.

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

Read Why Runtime.exec() won't work?

If you are using Java 1.5 or more, look into ProcessBuilder class which has replaced the old "exec" way of spawning processes.

kvprajapati commented: Great! +6
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> data[k + 1] = new Boolean(false);

Better yet; data[i][k + 1] = Boolean.FALSE . Same result, no unnecessary object creation.

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

> Can anyone help? help

Check if the Client class has a no-arg constructor in case you have explicitly provided a overloaded constructor. Also, looking at the error message gives an indication that you are not placing your class in a package. Make it a habit to put your classes in packages, *always*.