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

This question would be more appropriate in the CSS/HTML forum. Moved.

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

This question would be more appropriate in the CSS/HTML forum. Moved.

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

> How much do you spend a time on sleep ?

If time permits me, almost around 13 hours a day.

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

Jonhlennon312, considering that this is an international forum reaching out to help one and all, we would really appreciate if you posted in English so that everyone can benefit from your post.

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

Plus consider using Apache Commons File Upload package rather than doing it yourself given the kind of nifty functionality it offers.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
  • Looking after my family
  • Anime
  • Sleeping
  • Staring at the sky/ceiling
  • Punching holes in happiness
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

This greed is what keeps most of the forums out there alive so cribbing is kind of pointless. This world works on a 'give and take' principle.

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

> I think we need more focus on the content and less on silly rating and ranking systems for
> the members who post it.

Believe it or not, there are people out there who actually feel like helping others if they get something in return; and things like post ratings, reputations, best answer etc. actually makes them happy. Think of it as a motivator for the majority out there. :-)

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

> what require if someone want to be a team colleague, featured poster,moderator, etc ??

Don't think a lot about it. If you are good enough, these things will anyways come to you sooner or later. Just keep helping out people and above all, have fun. :-)

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

> I want to use database MS-Access, how to connect the jsp to Ms-access, plse send code

Asking for code without putting in any effort is against the forum rules. Plus avoid cross-posting. You already have got replies in you other thread. This thread is now closed.

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

> even if my parent window reloads, it should still be able to hold the child window
> references.

AFAIK, you simply can't. To put it in simple terms, the Javascript variables disappear after a page reload. After all Javascript is a client side technology.

A work around would be to store all the information you need to maintain inside a cookie i.e. whether the child window was open or not and if yes then what were it's contents; at the same time being aware of the 4KB limit imposed on the cookie size.

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

The deleteRow(index) approach used here is much better than the ad hoc removeChild() approach IMO.

Here is my stab at it (untested)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
            "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <meta http-equiv"Script-Content-Type" content="text/javascript">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="Expires" content="0"> <!-- disable caching -->
    <title>Example</title>
    <script type="text/javascript">
    function deleteRows(id, toDeleteHeader) {
      var obj = document.getElementById(id);
      if(!obj && !obj.rows)
        return;
      if(typeof toDeleteHeader == 'undefined')
        toDeleteHeader = false;
      var limit = !!toDeleteHeader ? 0 : 1;
      var rows = obj.rows; 
      if(limit > rows.length)
        return;
      for(; rows.length > limit; ) {
        obj.deleteRow(limit);
      }
    }
    </script>
</head>
<body>
  <table id="tbl" name="tbl" border="1">
  <thead>
    <tr>
      <td>No.</td>
      <td>Content</td>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>1</td>
      <td>Something</td>
    </tr>
    <tr>
      <td>1</td>
      <td>Something</td>
    </tr>
    <tr>
      <td>1</td>
      <td>Something</td>
    </tr>
    <tr>
      <td>1</td>
      <td>Something</td>
    </tr>
  </tbody>
  </table>
  <br><br>
  <a href="#" onclick="deleteRows('tbl', false);">Delete rows</a>
</body>
</html>
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> another odd thing, is that I do not see the form in the source when viewed by the client
> browser, is this just a fact of life for dhtml

Yes, because it's the Javascript object XMLHttpRequest provided by the browser at work when fetching content using Ajax. AFAIK, the actual DOM contents at any point in time can be viewed in Firefox using the tool DOM Inspector.

> onClick="javascript:validate_form();"
Don't use Javascript pseudo protocol. It was meant only to be used inside the href attribute of links.

One of the ways to narrow down your problem would be to put a DOCTYPE declaration at the top of your page (without which the browser goes in quirks mode of rendering, in short you have an invalid HTML document) and validate your generated markup at W3C validator.

The next step would be to use the FF error console for spotting errors which don't show up in IE just because IE let's them "slide".

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

YEAH I Know... Ill be up to you in NO TIME

You have already started your journey the 'Bennet way' it seems.

Hint: Your signature.

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

Since you need to set the bean in the session scope, you need to do something like session.setAttribute("YourBeanName", yourBeanReference); . Read the form values in a normal manner; the same way you would do for a normal form submission i.e. request.getParameter("formFieldName");

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

Happy B'Day Holly boy! :-)

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

I would be assuming that you are using JSF as your UI framework here along with JSP as presentation technology. Even if you are not; the below discussion should be applicable to your problem more or less.

You have an 'escape' attribute for the HtmlOuputText since it's a display only entity and you might want to have complete control over how the data is presented to the client without manually doing the conversion every single time. HtmlInputText doesn't have an 'escape' attribute; actually it shouldn't have an escapeXml attribute since the data entered by the client should reach *as it is* to the server.

That being said, the only problematic area I see is the validation code which automatically converts all the < and > to their HTML Entities. It must be that even when the validation succeeds, the user input is still getting processed and converted to a String having HTML entities in place of < and >.

It might be a good idea to clearly explain your problem than to let the ones helping you out do all the guesswork. You bring up terms like HtmlInputText and validators as if they are commonplace here which isn't the case since they are not part of plain vanilla JSP API. Post the relevant code if you still encounter problems and don't forget to enclose the code in code tags; read the forum announcements regarding that.

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

Yes, submit the form to a servlet, perform the processing and redirect to a page whose output you would like to have in responseText attribute of the XMLHttpRequest object.

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

The code posted seems good enough though I am pretty much confused as to how these parts fit in the entire application or the page itself.

Values set in the session are not persisted across requests only when there is some problem with session creation. Make sure your localhost or your dev server is in trusted zone and cookies are enabled. Playing around a bit with the session object; i.e. setting some variable in session scope and retrieving it on the next page should give you a good idea on where exactly the problem lies.

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

> Is it necessary to declare an inner class private?

No. Here is some information which you would find useful when learning about Inner Classes.

EDIT: Too slow.

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

> I'm incredibly confused by what you just said but I'll take your word for it that if I read all of
> these tutorials that, by the end, I'll have a much clearer understanding

You shouldn't be; the basics as well the pretty advanced stuff remains more or less the same. My recommendation would be the book 'Mastering Regular Expressions' which is a must read for all those who want to be regex gurus.

Though the basics are the same, the application of regular expressions depends a lot on the language you use, so unless you consult your language documentation, you might be in for a big surprise. :-)

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

You were having a hard time debugging this simple snippet because maybe you were testing this code in IE; for debugging use Firefox. It provides good debugging support given it has error console (Tools -> Error Console). To try it out, run your previous snippet which you just posted in Firefox and look at the error console; the errors would be right there.

If you are up to it, you can even try the Firebug plugin which provides full blown debugging. And you can be pretty sure that if something works in Firefox will also work in IE.

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

And to think all this time I have been replying to threads in an Ad-hoc manner. ;-)

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

Something one can wear on his hand and use it to rip out someones' intestines.

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

The action attribute of your FORM tag should point to the servlet which would be doing all the processing. The servlet path can be obtained from the web.xml and is the same as the url-pattern for that servlet. In your case it should be <form action="results"> .

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

There are no try...catch blocks around that switch statement of yours considering that any parseXXX method is very much capable of throwing a NumberFormatException. Plus writing parseInt(xxx) or parseDouble(xxx) in every switch case seems kind of redundant.

Also a status code of '0' denotes success so your System.exit(0) should be System.exit(1);

A better way to do the entire thing would be:

package daniweb;

public class Tmp {

    public static void main(String args[]) {
        args = new String[]{"/", "s", "r"};
        if (args.length != 3) {
            System.out.println("Usage: java Calculator operand1 operator operand2");
            System.exit(1);
        }

        double result = 0.0;
        ComputationUnit unit = new ComputationUnit();
        unit.populateFromCommandLine(args);
        try {
            result = unit.compute();
            System.out.println(unit.getOp1() + " " + unit.getOperand() + " " + 
                    unit.getOp2() + " = " + result);
        } catch (IllegalArgumentException e) {
            System.out.println(e.getMessage());
        }
    }
}

class ComputationUnit {

    private double op1;
    private double op2;
    private char operand;

    public ComputationUnit() {
        super();
    }

    public ComputationUnit(char operand, double op1, double op2) {
        this.op1 = op1;
        this.op2 = op2;
        this.operand = operand;
    }

    public void populateFromCommandLine(String args[]) {
        try {
            operand = args[0].trim().charAt(0);
            op1 = Double.parseDouble(args[1]);
            op2 = Double.parseDouble(args[2]);
        } catch (NumberFormatException nfe) {
            System.out.println("Please enter a valid number: " + nfe.getMessage());
            System.exit(1);
        } catch (Exception e) {
            System.out.println("An error occured: " + e.getMessage());
            System.exit(1);
        }
    }

    public double compute() {
        switch (operand) {
            case '+':
                return (op1 + op2);
            case '-':
                return (op1 - op2);
            case '*':
                return (op1 * op2);
            case '/':
                return (op1 / op2);
            default:
                throw new IllegalArgumentException("Unknown …
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Where have you declared 'slopetop', 'slopebottom' and 'slopefinal'? And document.write() is evaluated as the page is being rendered. Plus Javascript is a client side technology; as soon as a page is submitted, what you get is a new page and the state maintained in Javascript variables is reset.

You need to dynamically update the value of a span or div element to get this code working as expected. Something like:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
            "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta http-equiv="Expires" content="0" /> <!-- disable caching -->
    <title>Example</title>
    <script type="text/javascript">
    function calculate(frm) {
      if(!frm)
        return(false);
      var elems = frm.elements;
      var x1 = parseInt(elems['inpx1'].value, 10);
      var x2 = parseInt(elems['inpx2'].value, 10);
      var y1 = parseInt(elems['inpy1'].value, 10);
      var y2 = parseInt(elems['inpy2'].value, 10);
      var e = elems['result1'];
      alert("(" + x1 + "," + y1 + ")" + " and (" + x2 + "," + y2 + ")");
      var distance = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
      e.value = isNaN(distance) ? 'Invalid input' : distance;
    }
    </script>
</head>
<body>
  <form action="#">
    <div>(<input type="text" name="inpx1" size="5">,<input type="text" name="inpy1" size="5">)</div>
    <br>
    <div>(<input type="text" name="inpx2" size="5">,<input type="text" name="inpy2" size="5">)</div>
    <br>
    <input type="button" onclick="return calculate(this.form);" value="Calculate!">
    <br><br>
    <div>Distance: <input name="result1" readonly="readonly"></div>
  </form>
</body>
</html>
3265002918 commented: I suck a javascript (presently). Thanks. +3
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Have you tried outputting the value in your servlet to see what it is receiving? Form values are submitted as they are; the job of encoding and decoding is automatically performed by your browser unless you are manually submitting the form using Javascript.

Also AFAIK, no database performs automatic conversion to HTML entities. Are you using any external libraries in your project? Anyways, printing the values submitted in a servlet would help us in coming one step closer to the solution.

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

AFAIK, JFreechart can also be used to create dynamic on the fly charts. Read the documentation and the tutorials floating around the web and it shouldn't be that difficult.

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

If you are talking about getting the values of a drop down list at the server side, it can be done by doing request.getParameter("nameOfSelectBox"); A better way of displaying the user list will be render it as table with the user id hyperlinked which would then take the user to the corresponding page when clicked.

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

No, AFAIK, you can't control that.

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

Yes, start off with the excellent J2EE 1.5 tutorials available on java.sun.com which guides you through building a sample web application or get a good J2EE book and start reading.

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

form.submit() causes a form submit irrespective of whether that form has been assigned a real or dummy action. Plus on a page at a time only one form can be submitted. The best way here would be to rethink your design and encapsulate all the elements in the same form and perform the arbitration logic at the server itself.

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

Please let us again not go path of discussing why and how ads are evil; this topic has been brought up and beaten to death time and time again. Maybe it's time to mark this thread as solved...

John A commented: sigh... +14
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You missed the point of my post; the problem is that back stabbers and ass-kissers are also polite so it becomes pretty difficult to distinguish between them and the people who are *actually* polite and mean what they say.

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

Insert line breaks in server side code, in your case that being ASP. The formatting will be preserved as it is in the textarea. Your rendered textarea should look like:

<textarea cols="55" rows="10" name="txtDescription">Location: Atlanta-30th Floor-3034B
Occupant: Andersen, Jason
Current Station Type: Floor Shared</textarea>
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Maybe a custom function like getElementsByClassName() ?

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

> I have a form text field called "field_0", and javascript code:

First of all, your markup is broken. The HTML tag attributes need to be in the form of key-value pairs with the value being enclosed in double quotes.

> However if I change a little in javascript code this script will no longer work

This is because your JS code now looks for an element with the name 'fd' instead of 'field_0'. Try something like document.form1[fd].value .

But the way you are accessing forms is fundamentally broken, read this excellent article on form access.

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

There are different ways of persisting data across multiple requests; session object being one of them. You can save the create a bean class for all logically related data and store its instance in the HttpSession.

Another way would be to use hidden form fields to pass values to and fro and maintain them across requests. The disadvantage here is that each time you land on a page, you need to create hidden form fields which would hold the data that needs to be passed to your target page.

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

Being polite is one thing, back stabbing and ass kissing another. Maybe he was talking about the latter ones...

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
            "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta http-equiv="Expires" content="0" /> <!-- disable caching -->
    <title>Ajax Example</title>
    <script type="text/javascript">
      function check(frm) {
        var dataIsValid = true;
        /* all your validation/processing code goes here */
        if(dataIsValid) {
          alert("Form successfully submitted!");
          return(true);
        } else {
          return(false);
        }
      }
    </script>
</head>
<body>
   <form id="frm" action="#" onsubmit="return check(this);">
    <label for="txtName">Name:</label>
    <input name="txtName" id="txtName">
    <br>
    <input type="submit" value="Submit form">
   </form>
</body>
</html>
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Glad I could help. :-)

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

> This thread really belongs in one of the lounges.

Completely agree. Done.

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

No wonder he hates being called a 'sweety'...

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

Have a look at the Javaworld article 'Solving the logout problem elegantly' to get a fair idea of how to go about doing things.

Sulley's Boo commented: riiiiiiiiiiight +5
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Yes, even whitespace counts as a character. To detect a whitespace, use the function Character.isWhitespace(char ch) .

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

> w000000t 10,000th post!!!!

W00t, unbeaten spammer!! ;-P

Congratulations BTW. :-)

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

> Sharp eyes, good job for noticing that.

Wasn't it expected given the bulging eyes? ;-)

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

> The following works correctly in IE7 but doesn't work in Firefox. Any idea?

Because you are trying to retrieve the element using the id "testfield" but you don't have any element having an id "testfield", only one with a name "testfield". It works in IE because IE approximates or works with names if it doesn't find an element with a given ID. Form names are best accessed using the elements collection of the form object instead of searching for the element based on it's ID which is much slower. Read the Form access tutorial for more details.

> if(offset!==undefined)

Use if(typeof(offset) == 'undefined')) > <input name="testfield" type="text" value size="12"> <input name="testfield" type="text" size="12"> You don't need to specify an attribute if you are not using it and if you do, it needs to have a value, it can't be left blank. So it should be value="" .

> Also, is there any way to get IE to quit waring people of active content when they open
> this page with the annoying menubar thing?

It is some kind of weird security feature IE7 has implemented. I don't use IE but maybe this topic would be of some use to you.

> An lastly is there a way to get the field to autopopulate when someone loads the page
> instead of the user having to click the button?

Yes, attach a function to the onload event …

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

I am not quite sure that I understand what you are trying to say here but if you are worried about the number of characters displayed per line on your console window, it depends on the properties of the console window (OS specific) and has got nothing to do with your program. For e.g. in Windows you can set the properties of the console window like Screen buffer and window size to increase / display the number of characters displayed.

If still in doubt, post the code along with the varying output you are talking about.