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

Sorry, but message boards don't work that way. You can't delete a thread you created just because you managed to solve the problem and no longer need the thread. Imagine the chaos if everyone started requesting deletion of the threads they started...

Please exercise caution next time when asking for homework help on Daniweb or as a matter of fact any forum. Fire off a PM to Happygeek in case you need more details.

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

As long as you are using IMG tags to render images, you can use the document.images collection rather than the usual document.getElementById function to grab image references. Regarding the innerHTML snippet, since the element with ID 'caption' is a DIV, you can't use the document.images collection.

BTW, try to experiment more; play around with the suggestions offered rather than being afraid to try them out. Trust me, you'll learn a lot more this way.

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

AFAIK, no. But is there any reason why someone would require that kind of functionality?

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

Just to set the context straight here:

it is recommended not to use this attribute to find the images in the document

Since in this particular case the ID of the image is known, there is no harm in using the `images' collection though getElementById also works.

Using the images collection is logically better since entire scan of the DOM tree isn't required. This *might* make a difference in cases where the entire document has close to thousand elements but only a few images.

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

> Suggest not using image collection as you need to know the index
> of the image in question.

No you don't; please don't spread FUD.

var myImg = document.images['your_img_id'];
//OR
var myImg = document.images['your_img_name'];
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Like I had previously mentioned, there is no need to loop over the result of the split method call. The split method returns an array whose elements are the host, ip addr and the ping.

Just remove the "for (String str : values) {" part and you should be good to go. For future references, please make sure you post a compilable piece of code which can be easily copy-pasted and run without making the poster jump through hoops to get it working.

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

> if(w.blur)w.focus();

This checks the `blur' property of the window object and not if the window is having focus or not. Anyways, this isn't required, you can directly invoke the focus() function.

> pageURL = (!pageURL) ? '' : pageURL;
> imageURL = (!imgURL) ? '' : imgURL;
> if(pageURL == '' || imgURL == '') { return false; }

Or simply: if(!pageURL || !imgURL) return false ;

> var img = (document.getElementById) ?
> document.getElementById('popupImg') :
> document.all;

Or you can use the `images' collection of the document object which is supported by almost all browsers out there.

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

Post your latest copy of compilable code which exhibits the behavior you mention [i.e. duplicate printing] along with the relevant CSV file.

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

> it duplicates the information its printing out by 3

Because you print out the information in a loop. The solution here is pretty simple; split the string read from the file/stdin using the given delimiter. If the length of the resulting array is not equal to 3, it means that the input wasn't in the format required. If the array length is 3, print out the details using:

String[] arr = str.split(",");
// assert length of the array is exactly 3
System.out.println(arr[0] + ", " + arr[1] + " and " + arr[2]);
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

OK, thanks for finally getting the point. BTW, this thread is going down on grounds that it might again turn into a "hail narue" chant by Serkan and for going a bit too off-topic.

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

Indeed, that's why I specifically mentioned a no-arg constructor[in case the class already has one] and not a default constructor. A default constructor is a no-arg constructor but the reverse doesn't make sense since if you explicitly define a no-arg constructor, there isn't anything *default* about it.

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

> I was wondering why do we need constructors with arguments?

  • Creation of an object based on an existing one [though this can be done the `Cloneable' way, constructor based approach is also pretty flexible]
  • Creation of an object with known state [bind the ServerSocket to port XXX]
  • Prevent creation of objects with invalid initial state [by making the no-arg constructor as private. E.g. you wouldn't want a Policy object in your financial system to have a blank state; a Policy business object if created *always* has an initial state in the form of a policy number and other mandatory attributes. Ditto with Streams in Java and so on]
verruckt24 commented: Full marks !!! Explains (concisely) everything. +4
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I think the OP is talking about the "copy constructor" like functionality which exists in C++ and can be implemented in Java by:
- implementing the Cloneable interface
- overriding the clone() method of the Object class

@grisha83

Read the documentation of the clone() method of the Object class and this for more details.

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

A ban is a result of a member gathering up 10 infraction points. Each infraction has a time duration till which it is active. Once the duration expires, the member is automatically unbanned and can start posting again. I think that this pretty much serves as a decent "rehabilitation" measure.

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

> please check this!

Whenever I get the feeling of alien intervention when browsing Daniweb, I normally press CTRL + F5 ... ;-)

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

You don't need to make your servlet implement the Runnable interface; each request is anyways handled and served in a separate thread. The destroy method of a servlet is called when the servlet is put out of commission. As an exercise, try shutting down Tomcat and monitor the SDTOUT or log files for your message string "hhello0".

I would recommend reading the JEE 5 tutorial to know more about servlets.

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

> Why should I do this(in bold)? :

Because we require the hex equivalent a generated byte and not the integer this byte gets up-casted to. When converting to hex string, we would want our toHexString() method work on an integer which represents the sequence of bytes generated by md5 and not the integer which the byte value gets automatically upcasted to.

For e.g. if the first byte generated by the md5 algorithm in your case (with input "abhi") has a binary pattern "11010111", we would want the hex equivalent of an integer having the same bit pattern i.e. "00000000000000000000000011010111". But the integer which results from the auto-conversion of "11010111" is of the form "11111111111111111111111111010111". Hence you need to AND the byte in question with 0XFF [00000000000000000000000011111111] to make sure all the higher order bits other than the byte in question are reset to 0.

> Isnt it the incorrect output?

Read the python documentation, hexdigest() is the method you should be looking for.

abhi_elementx commented: It's very informative +2
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Don't use generics for your InfiniteInt class; it will *always* be a DLL of type Integer [or in general Number]. Instead create your InifiniteInt class by extending the DLL class and specifying Integer as the type parameter.

class DLL<T> {
  // A DLL of objects of type T
}
class Infinite extends DLL<Integer> {
  // integers expressed as DLL of Integer objects
}

Also, how do you propose to handle negative integers?

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

GZIP or any other compression when used for web applications is almost/always at the web server/web container level rather than the framework/technology used. Do a web search for 'gzip apache' or 'gzip tomcat' for more details.

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

Though you can't do Class.forName on primitives, you can use the following trick for wrapper classes:

Class klass = (Class)Class.forName("java.lang.Integer").getField("TYPE").get(null);
Method m = new Test().getClass().getMethod("doForInt", klass);		
System.out.println(m.invoke(new Test(), 1));

You can have a map which maintains a mapping of primitive types to their wrapper equivalent i.e. "int" => "java.lang.Integer" and use the above trick to pull in the class object of primitives. A bit convoluted but pretty much does the job.

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

You don't need to change the signature. You can obtain the `Class' instance of the primitives using either `int.class' or 'Integer.TYPE'.

import java.lang.reflect.Method;

public class Reflection {
	
	public static void main(final String[] args) throws Exception {		
		Method m = new Test().getClass().getMethod("doForInt", int.class);
		System.out.println(m.invoke(new Test(), 1));
	}

}

class Test {
	
	public int doForInt(int i) {
		return i;
	}
	
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Also, consider moving the `parse' method to a separate implementation class coded to an interface to allow for greater flexibility.

Is that file format predefined or something which you have designed yourself? If the latter, then there are better ways of representing the same information. Just move all the point coordinates on a single line removing the comma in between them. Read a single line from the file and split it with `space character' as a delimiter. If the size of the array after split is not divisible by 2 [the number of coordinates which constitute a point in 2D], consider it to be an invalid set and skip the computation. If the size is divisible by 2, then the size of the point array should be the size of the split array divided by two.

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

When do you think the compile time error 'symbol not found comes up'? What does your text book say about such errors? The example you posted seems a pretty bold one for someone who has just started out with Java.

Anyways, the error message means that the compiler doesn't know about the token 'DateFormat'; `import' the class in question and you should be good to go.

redmaverick commented: Thanks for helping me out! +1
Salem commented: Kudos for bothering to trawl through zero-indent code. +29
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> it also supports the idea of how c++ sucks.

Just because Linus thinks C++ sucks doesn't mean we feel the same way; he isn't god you know. Also, AFAICT, he is trying to say that:
- C++ is a difficult language, at least when compared with C
- There are more ways to abuse and more substandard programmers in C++ than in C

As an analogy, please don't hate your OS just because it allows you to format a partition with a single click; with great powers come great responsibility...

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

If the entire code base uses generics, there is no way that would happen; after all, generics were introduced for this very reason. Are you sure that the code base doesn't ditch generics and falls back to raw collections at some point? Have you used a debugger to trace the program flow so as to view the methods which add data to the vector?

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

Thanks for your precious reply...!

No actually i have got selected for a IT Company.... There i have to join by August 2009, so within that period i have to make up my mind and learn lot of things by practical, before entering the company....
So as per your advice, i have to use framework right...?
What are all the frameworks available....
Is Struts OK...?

If you have just joined, it would be better to dabble and understand plain JEE stuff; they anyways won't be expecting any framework expertise from you. Reading the entire JEE 5 tutorial and if possible Core JEE design patterns would be more than enough. Practice is the key here; make sure you don't end up reading things without knowing how they work.

> For the major ones there are Struts, JSF, Spring

I would rather not recommend JSF; I personally find it to be an abomination from hell. Struts2 is out BTW, so if you are picking Struts, you might as well go for Struts2. Tapestry and Wicket seem promising.

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

> what is wrong with being "Narue obsessed"?

Nothing is wrong in being obsessed with 'XXX'; just make sure you don't end up causing inconvenience and chaos with your *obsession*[which you just did by posting this thread in C++ forum, making it an off-topic thread].

stephen84s commented: Yep this obsession had gone over the line last time also +8
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> i want him taken out.

If you stop posting here, you might never see him again...

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

> Can we have two servlets in one single project... Is it possible...?

Yes.

> Is it mandatory....?

No.

Normally, a single servlet is good enough to act as a controller for your entire application. Read the JEE 5 tutorial along with this thread on the google group.

Any reason you are not using one of the many frameworks out there to ease your task? Is this college assignment / homework / practice? If not, then your really should.

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

> I am having a null pointer error, don't know where it came out.

Locating the cause of exceptions is something every Java programmer should be proficient in. Study the stack trace and use a debugger[or debugging statements] to locate the source of problem, *yourself*.

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

> http://redwing.hutman.net/~mreed/warriorshtm/acne.htm

Gah, I was hoping for a quiz to do it for me; reading through all that stuff just to know who you are is so...mendokse.

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

It isn't a link when you are viewing your profile [i.e. when we click on our user name]. Navigate to the CP [control panel] wherein in the 'Latest Reputation Received' is shown as a link.

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

Your question is a pretty generic one and can be roughly translated to "how would I go about developing web apps using JSP and Servlets?" in which case you should:
- Start off with the JEE 5 tutorial/documentation
- Read the sticky at the top of this forum for a sample project
- Buy some good books
- Re-post if you have specific problems.

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

> Please Explain. Where i have to change the code?

Try changing your markup; your HTML page doesn't understand your *servlet project* and hence you need to specify the extra "/test" before your servlet name.

> So where i have to include DB Connection code?

In your DAO classes.

> i have reffered many books but i didnt get the proper
> knowledge... Help me please.....

Refer the sticky thread at the top of this forum along with the JEE 5 documentation for some concrete examples.

stephen84s commented: Ah... So is it finally the return of the king ??? :P +7
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The program seems a bit off. No need to implement Servlet; you are anyways extending HttpServlet. The DBInterface and RequestDispatcher members of your servlet class will be shared among all requests since each HTTP request spawns off a new thread which invokes the doXXX method [based on the request type]; if you need `request' scoped data, do all the processing and initialization in the doXXX methods.

Read the sticky at the top of this forum and the JEE 5 documentation to get started rather than experimenting with your concepts still in nascent stages.

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

An observation regarding pop-ups -- don't you think it would be nice to show the pop-up to a non-registered user only *once* rather than showing it to him/her everytime he visits the Daniweb home page. A cookie based tracking might just do the job...

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

That wouldn't be unit testing...

Let's suppose I have a class which implements two methods; finding the cube of a number and finding the square root of a number. As long as appropriate unit test cases are in place for each method, does it really matter how the combination of them would work?

Unit tests generally exercise the public API exposed by classes and run in isolation. This is the reason why mocking frameworks exist...

IMO, stacking up method calls in your unit test cases won't add any value to them.

~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

IMO, the error is pretty obvious. What you need to do here is start small. Instead of getting an entire application to work, concentrate on miniscule exercises. Something like:
- Having only one text field on your page and displaying the value on STDOUT after the user presses submit
- Now validate the value and print appropriate message
- Insert the validated text in database

Read some good online books to get a grasp of how a JEE application is structured and how it all works. Explaning the *entire* application flow is something no one would be willing to do IMO...

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

Read the sticky posted by Peter at the top of this forum for a sample web application.

Also read the JSTL primer series at Developerworks which demonstrates building a blog using plain old JSP with JSTL used for presentation.

Read the official JEE5 tutorials for a brief overview of all the technologies/standards JEE incorporates.

> no need to tell i tried many tutorials in google, juz got nothing ..

Just because you can't find it doesn't mean it's non-existent. This kind of statement normally implies that the poster:
- thinks he knows everything
- is not ready to learn

Try not posting such statements on message boards since they hamper the count of responses you would have otherwise got.

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

> Hello, I have a form inside a form.

If possible, reconsider your design choice; nested forms violate the HTML specification.

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

> If I don't write a topic that has something to do with C++
> programming I'll get banned, so give me a moment please.

Not banned, the post will be deleted/moved. Anyways it still applies since your question still remains off-topic, I have moved it to the relevant forum. Now, flame on!

> Why is it that whenever I view posts of homework assignments and
> projects that a fair amount of the time (in Computer Science or
> C++), it seems as if--

You have seen nothing; go to the newsgroups and watch them shred you to pieces... :-)

On a serious note, I'll put down some random thoughts which haunt the minds of those who see "plz hlp" sort of posts:

- Time is precious
- Time is money
- Everyone has a life
- We can't read peoples' mind
- The help rendered if any is free; take it or leave it
- Search engines and books do exist out there
- Almost everyone hates leechers
- College work is better discussed with peers and professors
- Every human has a unique personality, whether you like it or not is a different thing altogether
- Life's a bit**

> Is Daniweb not a family?

No, seriously, it's an "IT Discussion Community". ;-)

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

> I have noticed this thread about anime and since I am also a fan I
> would like to answer that I have seen in total about 95 anime.
> Starting form Astroboy (1960) and the latest I am waiting to
> see is Gumdam Igloo

Since I started out quite late [around a year back] I haven't got a chance to see the same volume of series or classics like Astroboy.

BTW, feel free to post any anime related threads for recommendations or anything else; it would be nice to see more anime related threads here. :-)

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

Are you that kind of otaku also? :S

:-O , you're kidding right?

Haha, please don't ignore the poor smiley; though I won't deny digging in moe stuff. :-)

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

if > appears in html code as something you want displayed, it's supposed to be escaped at &rt; However, when commenting something out, <!-- --> then you don't escape it.

As already mentioned, I was actually quoting Midi and correcting him. :-)

Yup. For some reason Mod's refuse to use tags, they always use 4chan-style > quotes.
But they do give people infractions for not using [code]

[/code] tags...
Go figure :)

It's much of a bother to actually press the multi-quote button, remove the part from the post which I don't want to quote and then post an answer. Copy pasting the relevant part seems so much easier.

I use them less frequently than other people because [quote] tags are terribly bulky for quoting 1-2 lines. Plus, consider that a lot of us here have a history of using newsgroups and mailing lists, where '>' is the only accepted way of quoting someone.

Also, making multiple posts with each post addressing only a single post is a norm with newsgroup which probably would be considered spamming here. ;-)

Edit: Gah, I just used quote tags!

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

> Where's the hentai previews?

Alas I can't post them here. Believe me, if I could, I would. ;-)

> Hmm, this spring doesn't seem very interesting anime-wise.

Gah, you are too choosy. At least for now, any comedy/romance/action anime with a male lead should do the job for me. :-)

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

> -- is supposed to be replaced with an escape sequence when it
> appears in html code.

No it isn't.

stephen84s commented: I guess you better start quoting others' messages rather than you trade mark ">" sign :P +7
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

So, what doesn't seem to be working? Start off with a minimalistic approach rather than trying to incorporate the functionality into your existing complicated code. Use an excellent Firefox addon Firebug to debug your Javascript. You can view the Javascript errors in Firebug as well as Firefox's Error console [Tools -> Error console].

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

Use the class attribute of a HTML element [accessed in Javascript using the className property] for convenient grouping; for each new checkbox spawned, assign it a common class name like 'spawnedCheckBox'. Then filter out or select all the checkboxes with the given class name using the getElementsByClassName() function.

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

It's not OK, the return statement must go inside the catch block even when the function's contract is such that it *never* returns `null' for any input [as is the case with getElementsByTagName].

In languages which support Exceptions, there are usually two ways to break the execution flow of a function [ignoring the jmp variants offered by languages like C];
- A `return' statement is used to return from the function
- An exception is encountered and no appropriate exception handler exist in the given function.

> The other says they tested and never got an NPE - even if the
> value didn't exist, abc[0] returned an empty object (the test
> showed it returning empty curly braces)

There is a difference between `abc' being `null' and `abc' being empty. In the latter case, an undefined would be returned without the function throwing any kind of exception.

A variation of this scenario would be when there already exists a global non-empty array named `abc' in which case the return would always succeed. A sample:

<html>
  <head></head>
  <body>
    <script type="text/javascript">
    abc = [1,2,3]
    function doWithGlobal(obj) {
      try {
        var a = obj.b;
      } catch(e) {
        //do nothing
      }
      return abc[0];
    }
    function doWithoutGlobal(obj) {
      try {
        var a = obj.b;
      } catch(e) {
        //do nothing
      }
      return a[0];  //Error, since operation attempted on `undefined'
    }
    alert(doWithGlobal(""));
    alert(doWithGlobal(null));
    alert(doWithoutGlobal("")); //Error
    alert(doWithoutGlobal(null)); //Error
    </script>
  </body>
</html>

BTW, AFAIK, ECMA Error objects don't have …