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

You must be using browser specific features. IE is notorious in making your code run even when it is not correct. Paste the code and we will try to help you out. The only advice we can give you is to develop for Firefox so the possibility of the code working on other browsers is more plus you get a nice Error Console and tools like FireBug.

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

You need to specify the delimiter keeping in mind that its a regular expression pattern. If your input from the file is nothing but numbers separated by ',' without any space in between them, the code posted by you must work.

I am assuming that your code won't work since the delimiter you gave was only a single ',' while your input must have had spaces between the number and comma. (eg. 1, 3, 3). You should have input in this format (1,2,3,4).

If you want your code to work for something like(1, 2, 3,4, 5) :

String sample = "1 ,  2 , 3 ,4,    5";
st = new Scanner(sample).useDelimiter("\\s*,\\s*");
int k;
while(st.hasNextInt())
{
    k = st.nextInt();
    System.out.println(k);
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

^ A kid who is good at managing things, never giving up plus an ideal replacement for Eminem. :)

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

Now for something which is thought provoking and on topic....

A real life story from Seoul

My mom only had one eye. I hated her... she was such an embarrassment. My mom ran a small shop at a flea market. She collected little weeds and such to sell... anything for the money we needed she was such an embarrassment. There was this one day during elementary school.
I remember that it was field day, and my mom came. I was so embarrassed.
How could she do this to me? I threw her a hateful look and ran out. The next day at school..."Your mom only has one eye?!" and they taunted me.

I wished that my mom would just disappear from this world so I said to my mom, "Mom, why don't you have the other eye?! You're only going to make me a laughingstock. Why don't you just die?" My mom did not respond. I guess I felt a little bad, but at the same time, it felt good to think that I had said what I'd wanted to say all this time.

Maybe it was because my mom hadn't punished me, but I didn't think that I had hurt her feelings very badly.

That night...I woke up, and went to the kitchen to get a glass of water. My mom was crying there, so quietly, as if she was afraid that she might wake me. I took a look at her, and then turned away. …

vinod_javas commented: awesome! +2
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

There are a lot many ways of comparing dates depending on the source of dates and which class you are using to represent them (Date, java.sql.Date, Calendar), which would accordingly require some conversion.

Here is a simple example of comparing two java.util.Date objects.

public static void main(String[] args) throws ParseException
{
    Date today = new Date();
    Date before = new SimpleDateFormat("dd/MM/yyyy").parse("26/07/2007");
    if(today.after(before))
    {
        System.out.println("[" + today + "] lies after [" + before + "]");
    }
    else
    {
        System.out.println("[" + today + "] lies before or is the same as [" + before + "]");
    }
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

...which would work only for Windows.

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

> i want to compare dates in the date column with current system date.
Check the 'before()', 'after()' and 'equals()' methods of the Date or the Calendar class.

> now the problem is i have to compare these two fields
Without knowing the scenario, it would be difficult to suggest anything. Since one of the values is in the database, do the comparison in the servlet itself.

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

I had edited one of your posts a few days back which was 256 characters full of 'lol'. Overusing punctuation marks making the post difficult to be read should be avoided.

It seems as though you don't want to improve. Do expect an infraction in the future if this continues.

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

No, as far as I know, you can't do that. But you can surely get hold of all the elements which use that class and change their property which is what you must be aiming for, methinks.

<html>
<head>
    <style>
        .one
        {
            background-color: blue;
        }
        .two
        {
            background-color: green;
        }
    </style>
    <script>
    getElementsByClassName = function (needle)
    {
      var         my_array = document.getElementsByTagName("*");
      var         retvalue = new Array();
      var        i;
      var        j;

      for (i = 0, j = 0; i < my_array.length; i++)
      {
        var c = " " + my_array[i].className + " ";
        if (c.indexOf(" " + needle + " ") != -1)
          retvalue[j++] = my_array[i];
      }
      return retvalue;
    }

    function changeColor(name, color)
    {
        var elements = getElementsByClassName(name);
        for(var i = 0; i < elements.length; ++i)
        {    
            if(elements[i])
                elements[i].style.backgroundColor = color;
        }
    }
    </script>
</head>
<body>
    <form>
    <p class="one">Hello to all</p>
    <p class="two">Someone is here</p>
    <p class="one">Really? Who is he?</p>
    <p class="two">Do I know him?</p>
    <input type="button" value="Blue to Red" onclick="changeColor('one', 'red');" />
    <input type="button" value="Green to Yellow" onclick="changeColor('two', 'yellow');" />
    </form>
</body>
</html>
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Well... it does have "mother" in it at least...
I guess thats why I didn't infract him... :)

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

The URI you specify in your TLD file should be distinct and non empty. The URI used by your JSP file has got nothing to do with the absolute path of your TLD file. Just provide a arbitrary URI string like "http://yourname.com" in the taglib file and use the same in the JSP file.

If you are still getting errors paste the XML file.

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

Looping through each char in a string

public class Test
{
   public static void main ( String[] args )
   {
      String crap = "Hello";
      //loop through each char
      for ( int i = 0; i < crap.length(); i++ )
      {
         System.out.println ( crap.substring ( i, i + 1 ) );
      }
   }
}

Or better...

public class Test
{
   public static void main ( String[] args )
   {
      String crap = "Hello";
      //loop through each char
      for ( int i = 0, limit = crap.length(); i < limit; i++ )
      {
         System.out.println(crap.charAt(i));
      }
   }
}

- No need of calculating the length of the string for each iteration.
- A lighter function charAt() is much recommended if you only want characters rather than using the more generic substring() function.

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

In the case of OP's code, the overloaded method took arguments of type Object and String which is a subclass of Object i.e. a specialized object. Hence the String version of the code is called.

In case of Kashyap's code, the overloaded method took arguments of type String and Test, both of which were subclasses or Object i.e. specialized objects and hence the overloaded method was declared to be ambiguous.

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

^ The super-unknown :)

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

James there is a limit to going off topic. The topic is _Parents_ and you people are talking about _Motherboards_ !!

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

> I will ofcourse try and put the jsp and tld together as you say and let you know the outcome.
I meant post the contents of those files here. :)

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

Yes you have to create web.xml entry for that servlet program and also set the classpath to point to your servlet and jsp jar files.

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

Have you made the entry for your custom tag classes in the taglib.tld file? If yes, paste the JSP file along with the taglib.tld file.

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

Have you installed Tomcat? If yes, then the IDE which you must be using would have an option for setting the class path for you.

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

If you will look at the list of the things allowed in signatures...

Allow Basic BBCode [B]Yes[/B]
Allow Color BBCode [B]No[/B]
Allow Size BBCode [B]No[/B]
Allow Font BBCode [B]No[/B]
Allow Alignment BBCode [B]No[/B]
Allow List BBCode [B]No[/B]
Allow Code BBCode [B]No[/B]
Allow PHP BBCode [B]No[/B]
Allow HTML BBCode [B]No[/B]
Allow Quote BBCode [B]No[/B]
Allow HTML [B]No[/B][U][I][B]
Allow Smilies [B]No
[/B][/B][/I][/U]Allow [IMG] Code [B]No[/B]
Can Upload Images for Signature [B]No[/B]
Can Upload Animated GIF for Signature [B]No[/B]

I hope this clears up the matter... ;-)

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

AFAIK, no, you can't control the properties of something you don't create. Security reasons. The user is no sucker to come to your site only to find out his browser bare essentials have been stripped by some crazy developer...

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

Extreme off topic -- from monitors to cell phones...

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

> Java would be nice if Sun actually helped organize and certify the
> stuff that’s scattered all over the net.
I wonder whatever you mean by this...

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

"A man who doesn't embrace his past has no future."

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

I don't properly understand what you are trying to do here, but as far as I can make out, I guess you want to create a new window and allow it to load in the background while the user keeps on working with the original window.

// ee.html
<html>
<head>
    <script>
    function doSome()
    {
        var wnd = window.open("dd.html");
        if(!wnd.opener)
            wnd.opener = self;
    }
    </script>
</head>
<body>
    <input type="button" value="Open Window" id="btn" onclick="doSome();" />
</body>
</html>

// dd.html
<html>
<head>
    <script>
    function shiftFocus()
    {
        opener.focus();
    }
    </script>
</head>
<body onload="shiftFocus();">
    <div>This really is something.</div>
</body>
</html>

If not, then please specify which parameters you want to control.

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

> did anyone ask you bench?
Bad attitude. First in another thread and now this one. If you keep up this, I don't think you would be getting any help.

Always learn with an open mind and smile on your face otherwise getting help would become an herculian task.

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

Bench has given a good suggestion. But if you are not allowed to use maps, try using two parallel string arrays in which the location of the name of the animal and its description resides in the same location in their respective arrays.

const int SIZE = 3;
string animal[SIZE] = {"dog", "cat", "pig"};
string desc[SIZE] = {"bark", "meow", "oink"};

bool found = false;
for(int i = 0; i < SIZE; ++i)
{
    if(animal[i] == input)
    {
        cout << animal[i] << " -> " << desc[i];
        found = true;
        break;
    }
}
if(!found)
    cout << "No such animal exists";

I know this looks like a lot of work for a single user input, but is just another way of doing things, plus this is much more flexible approach instead of the hard-coded 'if...else' or 'switch' constructs. Since you are under going a programming course, I guess the focus would be more on logic and uniqueness than efficiency.

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

Mauro, more than 30 posts and you still don't use code tags?

Bench commented: Some people just never get it... +3
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Why?
Answer.

Bench commented: Good link, would have saved me the typing. +3
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

1. Define a structure.
2. Create an array of structures.
3. Read a line from the file and fill the array accordingly.
4. Accept input from the user.
5. Search the array given the input and pull out the required data.
6. Display the data
7. Repeat steps 4 - 6 till the user enters an '='.

Its pretty simple if you know how to do things. Read up 'struct' in your C++ textbook or search for some online tutorials to help you in that aspect.

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

> All they do is add a thin stub to the jar that launches a JVM and passes it that jarfile.
That is just one way of doing it. There are different ways of making an executable of which one is a true way of converting java file to an executable known an Ahead of Time Compilation. This is an interesting read.

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

> if there is any other way to control the window parameters, like while its loading, feel free to post
Set the focus to the parent window, so that the newly opened window can load in the background and the user can browse the original page.

If you still don't get it, let me know.

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

> Well, except for that very last person - they would probably still have one eye...
You the overlook the possibility of simultaneous eye stabbing.

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

"An eye for an eye makes the whole world blind."

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

Ah, pardon me, I misread the question, my bad.

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

The correct answer is 'Interwhaaa???'. ;-)

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

Get a good video player like VLC or MPStar. If the files still don't work, they must be corrupted.

sk8ndestroy14 commented: Thanks. +8
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

17" CRT's both at home and work. :-(

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

> ?
Rashakil is saying there are other bookmarking sites out there which exist for the same purpose of submitting links and articles. :-)

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

Same here while replying to threads and moderating.

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

Your XML file is not proper, there can be only one root element. Also since you have not posted the entire code, I would give you a small example on how to go about things:

// Javascript file

<html>
<head>
    <title>XML DOM</title>
    <script type="text/javascript">
    
    var xmlDoc;
    function parse()
    {
        alert('in parse');
        if(window.ActiveXObject)
        {
            xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
            xmlDoc.async = false;
            xmlDoc.load("notes.xml");
            display();
        }
        else if(document.implementation.createDocument)
        {
            xmlDoc = document.implementation.createDocument("", "", null);
            xmlDoc.load("notes.xml");
            xmlDoc.onload = display;
        }
        else
        {
            alert("Browser doesn't support XML DOM manipulation");
        }
        alert('out parse');
    }
    function display()
    {
        alert('In display');
        document.getElementById('b1').innerHTML = xmlDoc.getElementsByTagName("b")[0].childNodes[0].nodeValue;
        document.getElementById('c1').innerHTML = xmlDoc.getElementsByTagName("c")[0].childNodes[0].nodeValue;
        document.getElementById('b2').innerHTML = xmlDoc.getElementsByTagName("b")[1].childNodes[0].nodeValue;
        document.getElementById('c2').innerHTML = xmlDoc.getElementsByTagName("c")[1].childNodes[0].nodeValue;
    }
    </script>
</head>
<body onload="parse();">
    <p>b1: <span id="b1"></span></p>
    <p>c1: <span id="c1"></span></p>
    <p>b2: <span id="b2"></span></p>
    <p>c2: <span id="c2"></span></p>
</body>
</html>
// XML Document

<root>
    <a>
        <b>100</b>
        <c>200</c>
    </a>
    <a>
        <b>300</b>
        <c>400</c>
    </a>
</root>

In case of any queries, do ask again.

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

Try something like this. It would work for any kind of whitespaces (newline, spaces, tabs).

int main(void)
{
    char str[] = " hello \n   to all \n\r\f the \t people ";
    int limit = strlen(str);
    int i, change = 1, words = 0;
    for(i = 0; i < limit; ++i)
    {
        if(!isspace(str[i]))
        {
            if(change)
            {
                ++words;
                change = 0;
            }
        }
        else
        {
            change = 1;
        }
    }
    printf("Word count: %d\n", words);
    getchar();
    return(0);
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Maybe uploading screenshots would help us in understanding the problem in a better way...

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

If you have Firefox, see the Error Console to see if it shows any errors. If not then paste the code of both the files here otherwise we only end up guessing things.

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

If you feel that the syntax of VB is weird, try looking into Haskell and Erlang. You would really love it. ;-)

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

You have to change the Javascript code in the second page otherwise your purpose won't be achieved. Why can't you change the code in the second page?

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

AFAIK, you can't do that since before the document is being unloaded, submitting the form is an illegal action.

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

I would request all of you to enclose your code in code tags so that it looks like code and not some vedic mantra. Please read this.

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

"Science without morals is a curse."

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

> can anyone suggest me on how to remove the duplicate sequences from being displayed/generated
By using a better algorithm like 'Heap Permute'. See this. Though the solution is in C++, with almost no effort, you can port it to Java.

iamthwee commented: retarded... -2
Aia commented: Are you saying that as you look at the mirror? +6