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

Take a look at this post. It loops through all the options of a select box and checks for those which are selected. You can then construct a query string based on that.

For eg. if you have a select box name "selBox" from which you have selected two options "one" and "two", your query string should look like: url += "&selBox=one&selBox=two" ; Here one and two would come from the snippet I just pointed you to.

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

switch-case statements can check only integer or character values.

To be more precise, switch statements can handle all Integral types except long. Character values and Integral values are not separate entities as explained below.

A primitive type is predefined by the Java programming language and named by
its reserved keyword (§3.9):

PrimitiveType:
    NumericType
    boolean

NumericType:
    IntegralType
    FloatingPointType

IntegralType: one of
    byte short int long char

FloatingPointType: one of
  float double
Jishnu commented: Right. I was wrong in considering char as a different type. +2
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Try something like:

/**
 * Alerts out the selected item values of a select box
 *
 * @author sos
 * @param {HTMLFormElement} frm The reference to the form element
 * @param {String} name The name of the select box
 */
function show(frm, name) {
  var selOpts = frm.elements[name].options;
  for(var i = 0, max = selOpts.length; i < max; ++i) {
    if(selOpts[i].selected) {
      alert("Selected Item: " + selOpts[i].value);
    }
  }
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

MMORPG's FTW!

BTW, the poll is broken as Multiplayer / Single Player games are not genres but playing modes.

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

Wish you all a Happy New Year! :-)

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

Wish you all a Happy New Year!

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

Sounds good in theory, right? But let me explain.

Ever wondered why the 'Tutorial Section' of Daniweb is so thin as compared to the 'Code Snippets Section'? This is because submitting a tutorial requires Davey's approval. That's right, that's not something even a moderator or super moderator can approve.

Plus approval takes effort and expertise. Ever seen the articles submitted at professional sites? The subject matter of such articles is approved only after being read and re-read by professionals in that field. In short, it takes a certain amount of money and time to get such things done.

Now compare this with Daniweb. Here every moderator / super-moderator (I can't say the same about Admins and Staff Writers) is doing a free service to the community by doing his moderation duties. Asking them to proof read the articles submitted by Daniweb members / non-members and judging their credibility would be a bit too much to ask.

Of course Dani can employ people to make sure that the articles confirm with the standard but that takes money. Professionals are not cheap to hire and when I say that I really mean they are *expensive*.

Also consider a situation in which a C article has to approved. The C forum has around 6-7 moderators. So wouldn't it make sense to get the approval of the majority to avoid conflict? But then again it brings us to the problem of getting a *majority* of moderators to read and …

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

> why not make a section on Wikipedia itself and have a link to it?
Sounds like a good idea.

But allowing everyone to contribute would be like making a big mess out of it, not to mention it would stain the name of Daniweb in general, and choosing you would have the right to contribute would not be a trivial task.

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

> These classpath questions have simply become knee-jerk reactions. ;-)
You can say that again. :-)

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

Before assuming anything just do a System.out.println(Connector.open(url).getClass()) and see which class instance are you actually trying to cast.

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

> Class.forName("oracle:jdbc:driver:OracleDriver"); There is no class which goes by the name of oracle:jdbc:driver:OracleDriver . Replace those : with . and you should be fine provided you have included the classes12.jar or some other thin oracle driver in your classpath.

~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

> Hey, let me clarify. I don't mean that spellings aren't important. I'm just stating a point.
You should start noticing smiley's in posts. They help in knowing the sentiment with which the post was made.

> Wow, sos that was horrible.
It was a bait to attract all "leet"ers. Congratulations on being the first one in this thread...

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

Glad you could get it to work. :-)

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

More motivation for l33t speak. Sigh, what has the world come to. :-)

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

> She will give you a nasty black eye (at best) if you don't know here very well, or at all.

> You are a true gentleman, but I like to see you carry some 300 pound lady.

I will make sure I choose my target wisely. ;-)

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

Try downloading IE2, iCab (a browser), Opera 3 or Netscape 4 since these browsers are known to not support IFrames. Try downloading one of these and testing your page on it. But seriously, this is a dumb test since I am sure everyone must have moved with the times and has stopped using browsers from the stone age.

If you still continue with the test, let me know which browser works for your test.

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

> What i wanted was if the user wont have the Iframe support he may be provided with a web
> link so that he can click on it

So keep the link as a part of the content of the iframe tag.

<iframe src="somesource.html" name="frm" id="frm">
  <a href="somesource.html">
    Click here since your browser doesn't support IFRAMES
  </a>
</iframe>
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Wish all the people on this forum a Merry Christmas and a Happy New Year on behalf of me and my country. :-)

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

Huh? How can anyone other than Dani solve the problem?

The best you can do is to wait till Dani finds the cause and fixes this problem.

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

We have no way of knowing how your interface looks / how your table structure looks like. Next time try posting a more detailed explanation of how your application looks like.

There are some visible problems with your code:

  • Consider using PreparedStatement instead of normal Statement to get around the problem of SQL Injection and complicated quoting / unquoting.
  • NullPointerException is a runtime exception which can be very well avoided with a simple check. The very fact that you are catching it shows there is something wrong with your design.
  • And the most important of all, your SQL statement is hosed! The syntax of your update SQL statement is incorrect. UPDATE table_name SET column_name = value WHERE column_name = that_thing;
  • The logic seems to be incorrect. Do you plan on updating the wishlist of all those people who have the same wish? At least that is what it seems to me since you seem to be updating on 'wish' and not on the unique 'id'. (if you have one)

At least skim through the basic SQL and JDBC tutorial before you consider writing a web application. Start here and here.

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

One way would be to try to create an IFRAME element using Javascript. If that fails, you can be sure that the browser doesn't support IFRAMES. But this requires your user to have javascript enabled.

var e = document.createElement("iframe");
if(!e)
    alert("Your browser doesn't support IFRAMES");

Another way to notify your users would be to place the message between the IFRAME tag. Something like:

<iframe id="iFrm" name="iFrm" src="Source.html">
Your browser doesn' support IFRAMES
</iframe>

But it is pretty much a moot point since all modern browsers support IFRAMES.

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

Spiderman.

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

On the top left corer of your IDE, just below the toolbar icons, there would be a 'Services' tab. Focus on that tab, go to 'Servers' and expand that category. If you see Tomcat listed there, just right click on it and you will get an option to set the username and password.

A probably better way would be add a new server (if there isn't one) and follow the instructions given.

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

This is because Javascript searches for 'flow()' in the global scope but it so happens that your declaration of flow being present in the function imageFlow is not visible / is not a property of the global object. This can also be attributed to the fact that setTimeout and setInterval always search the global scope.

You can avoid this in many ways, two of which are: Either set this function flow as the property of your function imageFlow or use closures / anonymous functions.

/* Setting the property of imageFlow function */

function imageFlow() {
	var R = 0, x1 = .1, y1 = .05, x2 = .25, y2 = .24, x3 = 1.6, y3 = .24, x4 = 300, y4 = 200, x5 = 300, y5 = 200;
	var DI = document.images, DIL = DI.length;
	var flow = function() {
	    for(var i = 0; i < DIL; i++) {
	        DIS = DI[i].style;
	        DIS.position = 'absolute';
	        DIS.left = Math.sin(R * x1+ i * x2 + x3) * x4 + x5;
	        DIS.top = Math.cos(R * y1 + i * y2 + y3) * y4 + y5;
	    }
	    R++; 
	}
	imageFlow['flow'] = flow;
	setTimeout("imageFlow.flow()", 100);
}
window.onload = imageFlow;
function imageFlow() {
 var R = 0, x1 = .1, y1 = .05, x2 = .25, y2 = .24, x3 = 1.6, y3 = .24, x4 = 300, y4 = 200, x5 = 300, y5 = 200;
 var DI = document.images, DIL = DI.length;
 var flow = function() {
     for(var …
jmasta commented: Excellent explanation and example code +2
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I would rather prefer to carry her and walk around the puddle. Much classy and saves my coat. :-)

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

> window.location=randomlinks[counter]; This is incorrect since location is an object or a property of the window object and you are assigning a string to it. The correct way of doing it is location.href = randomlinks[counter]; ( window object is implied)

> counter = (++counter)%randomlinks.length; Don't see this would serve any purpose once the user has navigated away from the page after changing the href ...

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

> I prefer MS-DOS over any of the current systems.
Right....

And you are currently making this post sitting on an MS-DOS system. Great!

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

Creating a secure form has got nothing to do with Javascript. The javascript used under normal scenarios for enhancing the user experience and is client side only. In order to create a form whose data would be sent over a secure connection, you need to look into a protocol named as SSL (Secure Socket Layer).

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

> Oops, I did not expect anyone to take that seriously
Oh, did I sound serious? I suppose I could have used a smiley but I prefer not to. And to think we were talking about sense of humor. ;-)

> I have to admit that I love my own sense of humor way too much but I do hope some of it
> gets through to others.
Amen to that...

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

Then you are posting in the wrong forum. Start posting here and get your count to 200 before the end of the day...

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

A sample chapter on Data Structures in Java from the book Java concepts for Java 5 and 6. A good and thorough read.

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

...and spam.

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

Are you going to take Josh's place as grammar police? Fine. Just be aware that I don't like that dude, and will probably take it out on you.

...and you make sure you read the rules of this site before posting here. L33t speak along with threatening members with malicious intent is against the board rules and to quote you "Just be aware that I don't like that dude".

Keep It Clean

We strive to be a community geared towards the professional. We strongly encourage all posts to be in full-sentence English. Please do not use "leet" speak or "chatroom" speak.

What will happen: Offensive material will be snipped out of offending post or censored by bad words filter.
First offense: Member will be warned via user infraction system. Warning will be documented.
Second offense: 5 point infraction will remain on user's record for 3 months.


Keep It Pleasant

Do not troll by posting anything with malicious intent against another member (including, but not limited to, racist, sexist or religiously prejudiced remarks).

What will happen: Very derogatory posts will be deleted. Flame war threads will be locked.
First offense: Member will be warned via user infraction system. Warning will be documented.
Second offense: 5 point infraction will remain on user's record for 6 months.

And to be back on topic, I am annoyed by cocky kids who think they know better than everyone else, unable to realize that the way they look at things, when they are 17, …

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

If all you want to send is character data, why convert it to a byte stream unless what you posted was just a dummy example.

Some things you should know:

  • application/x-www-form-urlencoded is the default content type used to encode the form data, you don't need to explicitly set it. Similarly, the default content type of an HTTP servlet is text/html.
  • application/x-www-form-urlencoded is the wrong content type if you are sending bytes, you should use multipart/form-data to indicate that your request body contains binary data. (The term request body is relevant only when you are 'POST'ing your data)
  • For sending character only data you should consider constructing a query string having your data in the name-value format and posting it. Here is a small example:
public class ServletApp {
    public static void main(String args[]) {
        try {
            URL url = new URL("http://localhost:8080/mobile/postServlet.jsp");
            HttpURLConnection conn = (HttpURLConnection)url.openConnection();
            conn.setDoOutput(true);
            conn.setDoInput(true);
            conn.setRequestMethod("POST");
            String queryString = "name=sos";
            Writer out = new PrintWriter(conn.getOutputStream());
            out.write(queryString);
            out.close();
            Scanner in = new Scanner(conn.getInputStream());
            System.out.println("Data received--->");
            while(in.hasNext()) {
                System.out.print(in.next() + " ");
            }
            in.close();
        }
        catch(Exception e) {
            e.printStackTrace();
        }
    }
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> double word;
> print(word); //print unsorted array
> Arrays.sort(word); //sort the array
> print(word); //print sorted array

What are these things doing outside a method? Why is 'word' of type double and why is it declared as member variable of the servlet class which in itself lends to poor design since it would be shared by all your clients? What kind of an array do you want to sort -- an array of numbers or an array of strings? Nowhere in your markup (html file) do you provide the provision for accepting multiple values. You either need to provide such a provision or ask the user to enter values separated by some delimiter, for instance, a comma.

Assuming that you are trying to sort an array of strings provided by the user as comma separated values, you need to do something like this:

public class Sorting extends HttpServlet
{
    public void doGet(HttpServletRequest request,
         HttpServletResponse response)
            throws IOException, ServletException
    {        
        String word = request.getParameter("word");
        word = process(word);
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        out.println("<html>");
        out.println("<head>");
        out.println("<title>Sorting Servlet</title>");
        out.println("</head>");                  
        out.println("<body>");
        out.println(word);
        out.println("</body>");
        out.println("</html>");
    }
    
    public void doPost(HttpServletRequest request,
       HttpServletResponse response)
             throws IOException, ServletException
    {
      doGet(request, response);
    }

    public String process(String word) {
        StringBuilder buf = new StringBuilder(512);
        if(word != null && word.trim().length() != 0) {
            String arr[] = word.replaceAll("\\s+", "").split(",");
            Arrays.sort(arr);
            for(String str : arr) {
                buf.append(str).append("<br>");
            }
        }
        else {
            buf.append("<br>").append("No input supplied").append("<br>");
        }
        return(buf.toString());
    }
}

Having said all this, it's not a good …

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

> My water melocule still contains just one atom of oxygen and two atoms of hydrogen. Must
> be where the Indian water is different.
Correct. In fact, this is how the water "everyone" drinks is different considering "your" water "melocule" still contains "one atom" of oxygen and two atoms of hydrogen.

If you plan on throwing around sarcasm, don't ask someone else to "stifle up"...

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

> Sir, the water cannot be the same. The only thing "same" about it is the fact that its 1 O + 2 H.

Wrong. If you insist on getting into details, oxygen and hydrogen are diatomic molecules. So the equation is: [tex]2H_2\hspace{10mm}+\hspace{10mm}O_2\hspace{10mm} ->\hspace{10mm}2H_2O[/tex]

> The pollutants/contaminants will obviously differ in scale and nature by environment.

Pollutants/contaminants in what? We are talking about "drinking water" here. No one gives a damn to what kind of pollutants/contaminants water has before it is converted to potable water.

> You also have to consider the method each country uses to filter out the water.

It's the responsibility of the country to give its tax paying citizens potable water to drink. Does it even matter what method they use as long as I get clean drinking water?

> Don't call people ignorant when you don't act any better

I don't remember using that term. If you want to jump to conclusions, you are welcome, just don't blame it on someone else.

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

Still eating food and drinking *safe and pure* water...

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

> Just to expose your ignorance of India, you may read this news report:
Just to expose your ignorance, that isn't the place where I live. Next time check your facts before trying to act cool.

>> You live in India and drink the water, isn't that dangerous?
> Next time think before you insult someone.
Next time don't try to be sarcastic / pick a fight if you can't handle one.

Sulley's Boo commented: Jug jug jiyo mere shair *roar* .. hehehe .. (this is for the last rep comment u gave me) > tu bhari tu mota tu aloo ki bori tu tu tu tu tu bas tu kameene me tera khoon pee jaungeeee *slaps* +3
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Inline javascript code is really not recommended.

Firstly it is difficult to maintain since it clutters the already cluttered markup. Secondly, it absolutely lacks the separation of logic and presentation, something which you should definitely try to achieve always. Thirdly changing the logic may require changing the code at multiple locations. Having the functionality packed up or encapsulated inside a single function is much recommended.

Attach a listener to your onmouseover event handler to do the required job for you and encapsulate your image swapping logic in that listener.

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

> How is it different from the water you drink ?
Of course it isn't different. There is no point in bothering yourself with kids who have no idea of what they are talking about...

sneekula commented: Stifle yourself, I am not an ignorant kid! +2
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> AJAX something a novice can use?
That depends on what you mean by novice. If by noivce you mean someone new to programming then it would be a tough call. But if have any exposure to web development it should be a breeze.

> Can you recommend any books/website resources that will help me learn AJAX?
Joshua's Blog, Ajaxian, Ajaxpatterns and Jim Ley's site are good to go.

Ajax book reviews here.

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

> Building on what you already have
> onkeydown="handleEvent() Too many problems with the snippet you posted. First of all, Firefox expects you to pass the event object when invoking the event listener. It should be onkeydown="handleEvent(event) > var FirstTextbox = e.srcElement || e.which; This doesn't make any sense. e.which gives you the code of the key pressed while e.srcElement gives the element on which the event was fired. It should be var FirstTextbox = e.srcElement || e.target; so that the snippet works in both Firefox and IE.

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

Please post your code using code tags, you have been already asked to do this in another thread.

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

There is either a problem with your markup or the way you are using / including Javascript. Did you try the snippet pasted by me in the above post? Did it work for you?

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

Oh my, still eating food and drinking water.

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

Since it is you who controls the insertion into the database table, coding a listener which would notify or fire the refresh script as soon as insertion request for a particular table comes shouldn't be that difficult. Some other ways would be polling the table in consideration at regular intervals (by using a daemon thread) and firing off the page refresh as you have been doing till now as soon as a change is detected.

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

> what is dynamic web page
A web application normally consists of two types of web pages -- static web pages and dynamic web pages.

In the case of static pages, the content served by the web server in the event of that page being requested is the same across all clients (as long as the content remains unchanged). In the case of dynamic web pages the content served to the client depends on the request parameters sent along with the request object.

A dynamic web page is normally created using a server side technology / language like J2EE / PHP / ASP etc. which is interpreted at the server and served to the client in a format specified by the content type header. A typical example of a static web page would be the 'credits' page of a web site which would more or less remain static. Compare this with a web site search feature in which the page being rendered after the search depends on the query being made by the client.

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

Did you include the 'json2.js' script at the top of your page? It must be the only reason or it has got something to do with your HTML file since stringify() works for me.

<html>
<head>
<title>Forms</title>
<script type="text/javascript" src="json2.js"></script>
<script type="text/javascript">
function somename() {
    var o = objectify();
    var jsonString = JSON.stringify(o);
    alert(jsonString);
}

function objectify() {
    var o = {};
    var frms = document.forms;
    var formID = 1;
    var id = 1;
    
    for (i = 0, maxI = frms.length; i < maxI ; i++) {
        if (frms[i].name == 'form' + formID) {
            var frm = frms[i];
            var elms = frm.elements;
            var tmp = {};
            
            for (var j = 0, maxJ = elms.length; j < maxJ; j++) {
                var el = elms[j];
                tmp[el.name] = el.value;
            }
            o[frm.name] = tmp;
            formID++;
        }
    }
    return (o);
}
</script>
</head>
<body id="bdy">
    <form name="form1" action="#">
    <input name = "txtOne" value = "Text box one" />
    <input name = "txtTwo" value = "Text box two" />
    <input name = "txtThree" value = "Text box three" />
    </form>

    <form name="form2" action="#">
    <input name = "txtOne" value = "Text box one" />
    <input name = "txtTwo" value = "Text box two" />
    <input name = "txtThree" value = "Text box three" />
    </form>

    <form name="form3" action="#">
    <input name = "txtOne" value = "Text box one" />
    <input name = "txtTwo" value = "Text box two" />
    <input name = "txtThree" value = "Text box three" />
    </form>
<script>somename();</script>
</body>
</html>