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

> But you sure are cool !
Yeah, he is cool as molten magma. ;-)

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

Sanjay! You best watch the Super Bowl! You don't want to disrespect American culture, now do you? :P

Now only if I could get those American channels on my idiot box... ;-)

Now I am getting curious too dear sos, pray tell me what does global "actually" mean?

Simple, we don't want people to go all "Remember, this is mostly a European and American audience". It doesn't matter which country the majority of the audience is from since we don't base our decisions on that factor. We cater/treat each and every member the same way and in the same light irrespective of the country they belong. Hence, deliberately posting things aimed to cause discomfort to a particular religion is discouraged.

This also means keeping your hate list to yourself. We have had cases of people expressing their dislike to a particular culture/person/religion and make a huge issue out of it. On some other forum we had a sucker who thought all Muslims were terrorists; he was of course banned. We have seen suckers acting all high and mighty just because they thought that being from *The Privileged Country*, they could spit out any amount of BS they wanted, which is obviously dead wrong.

In short, anything which hampers / hurts the community spirit in view of the fact that the community is formed by *members* of Daniweb and not some people from country A or country B. The decision of what exactly crosses the line is subject …

Ancient Dragon commented: well said +23
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I am confused here, maybe you should paste the markup (HTML) next time so we have a clear view of what we are dealing with here.

Do you have a markup like this?

<input name="input[]">
<input name="input[]">

or like this?

<input name="input[0]">
<input name="input[1]">

If it's the latter, then what I have posted should work. You get hold of the first input element using document.forms[0].elements["input[0]"] . But if it's the former, there is no unique way of accessing the input element. That is possible only if you have an element with a unique id or a unique name. In that case, you do something like:

var els = document.getElementsByName("input[]"); // See this
for(var i = 0, max = els.length; i < max; ++i) {
  /* access the input elements using the index i. */
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> I was told this forum was global,

This fact still holds true. You seem to be having some weird notion of what global *actually* means.

BTW, I am with EnderX on this one.

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

I won't allow such threads to degrade the quality of posts at Daniweb. Thread closed until someone on the mod team decides/thinks otherwise.

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

Peter, the OP wanted to know how to check whether a JDK or a JRE path was provided during installation and not the environment variable PATH.

Ankita B, try running a simple servlet / jsp without using any beans and let us know if it works. The exception message clearly states it has got something to do with the classpath and it wasn't able to find the class you requested. Also you need to provide us the directory structure you are using, the problem is definitely at your end.

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

> I can follow your code apart from the first line.

I am just stepping through the elements of the array using a loop and comparing each element with the user input. If it matches, then the user has entered a correct password. If all the elements have been tested without a match, then the password is incorrect.

If you still have trouble understanding the basic programming concepts, maybe you should start off with some basic programming / javascript tutorials, practice a lot and attempt your project once you are comfortable with those.

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

> As the new Moderator on this forum, are you outlawing sarcasm?

My replies till now have got nothing to do with me being a moderator of this forum. I have been a member / moderator long enough to know when/where to draw a line. If I were to misuse my moderator powers to outlaw sarcasm as you say, I would have deleted his post and given him an infraction, which obviously hasn't happened.

> Remember, this is mostly a European and American audience

Remember, this is a global forum and has it's rules tailored for the same. Maybe you should go back and read the entire thread before coming to the conclusion that I am outlawing sarcasm.

nav33n commented: :) thanks for your kind words! But I gave him my answer already ! :P +3
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You need to iterate over the array and compare each array entry against the user input. Currently, you are comparing an array object with a string, hence the error.

for(var i = 0, max = arr.length; i < max; ++i) {
  var found = false;
  if(arr[i] == pwd) {
    found = true;
    break;
  }
}
if(found) {
  alert("Correct password");
} else {
  alert("Incorrect password");
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> I consider being called "a despised cocky kid" and insult! Watch your poor manners!

You started it all by dragging my country name into this discussion without any reason and turning a friendly discussion into what it is now. Keep your sarcasm/pointed remarks to yourself and if you can't, don't give out a cry when someone fights fire with fire.

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

> javaAddict had the write idea

Write? ;-)

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

> Good point! Sorry about being bad on your forum.

I despise cocky kids, and considering that you are still posting on this forum, you can be rest assured this ain't *my* forum.

sneekula commented: "Despiced cocky kid" is an insult! +0
Sulley's Boo commented: jeete rehh -_- +4
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> ArrayList still has nothing to do with a linked list, both are array-backed, so it doesn't really
> matter.

A linked list is not array-backed but composed of a chain of nodes, each pointing to the next in the chain or null, in case of the tail element.

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

> Hmm, looks like there is no such thing as the First Amendment in India.

What has this got to do with posting a reply to this thread? And you need to stop dragging someones' country name without a good reason.

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

> With that approach you can close down this (and other) threads.
I said *preferences* not *opinions*. Someone here needs to be on a lookout for smileys...

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

> how can i check if the path provided was to jdk or jre?

Create a very simple/minimalistic JSP which just outputs "Hello World" or some other random text, and try to access your web application. If it doesn't compile, it means that the path supplied was of JRE and not JDK.

> control panel->system->advanced->environment variables->new->CLASSPATH-> . ;

You don't explicitly need to set the CLASSPATH that way, remove it. The Tomcat class loader automatically takes care of it and makes sure it loads all the classes present in the WEB-INF/classes folder. The directory structure needs to look something like:

webapps
|--- myapplication
      |--- jsp file
      |--- WEB-INF
             |--- web.xml  
             |--- classes
                   |--- foo
                         |--- Login.class

Also, don't use scriptlets in your code, use JSTL. And first and foremost, read a bit more about the basics of Servlets/JSP's from the link suggested by me in one of the other threads. There is no point in trying to program something without even knowing the basics of it.

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

> Let's stick to reducing stress, not creating it.

Let's stick to keeping our preferences to ourselves. ;-)

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

> Personally I prefer the Vector class

This is a wrong choice on two counts. First, Vector implementation internally uses arrays so it's no different from using an array in the first place. The only thing different is that you would now have an array which you can grow / shrink on demand. Secondly, Vector is synchronized so you suffer a performance penalty of having a concurrency check even when you don't need it. Vector is anyways a bad choice even if you need to ensure correct access. Hand crafted concurrency using ArrayLists is far better than using Vectors. Google it up and you would find a lot of interesting things.

> I have an array of "Animals". I would like to be able to add to and delete from the array.
> This, however, is not efficient.

So why use arrays in the first place? Why not just go with LinkedList class from the util package if all you want to do is a lot of insertion/deletion?

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

> I am just wondering can a linked list reference an array in another class?
Yes, a linked list can contain references to an array of any reference type.

List<Integer[]> l = new LinkedList<Integer[]>();
l.add(new Integer[] {1,2,3});

It would have been easier had it been done without generics but if you are using Java 1.5 and above, generics is the way to go. Read up on generics and the Javadocs of java.util package for more details.

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

No worries, we will be on the lookout for good things and just ignore the bad things. ;-)

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

> Eat your girlfriend. And let her eat you too.

Kiss would be more like it, unless you really *are* a cannibal.

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

Take a look at JFreeChart.

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

Are you sure you provided the path to JDK instead of JRE during Tomcat installation? If yes, then paste your code (JSP along with Java files) and we will see what can be done.

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

> I have a little difficulty accessing a textbox value from a function.

Your HTML markup is all broken up, make sure you validate your markup before posting it here. You are incorrectly accessing form fields. Read this and this.

> f = getElementById(formName);

This is incorrect, getElementById is not a method of the window object, but the document object. Plus, it accepts an id and not name. Please make sure you verify the code you post.

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

Though it works, it's an incorrect way of doing things. location property of the window object is an object, not a string. The location object in turn has an href property of type string and hence location.href = "url"; is the correct, location = "url"; is not.

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

> The grading policy at the college I work at counts off heavily if someone writes self-modifying
> code or uses page attribute changes to control program flow.
Stifling the creativity/imagination of the kids? Oh my, I pity them.

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

Hi ,
can any one tell me how to disable the back button in asp.net
i have done like this
<script >
window.onlad = "window.document.forward(1)";
</script>

but no use...is there any other way to do this.

Look into the function window.location.replace. It should solve your problem. But criplling the client in such a way is not a good practice IMO; you should never control your clients' browser behavior.

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

Is form_input the variable holding the form name or is it the form name? If it's the form name, you need to enclose it in double quotes. If it still doens't work, test the page in Firefox, look at the error console and let me know what it says.

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

> As you get older, you realize that life is full of freeloaders. Luckily, some of us feel good
> about working, to have a sense of accomplishment etc.
Couldn't have put it better myself...

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

Think of the include directive as a header file of languages like C/C++. When using the include directive, the combined contents of the original JSP page and all its included resources are translated into the same implementation servlet i.e. the contents of the included resource is copy pasted before translation to a servlet. The important thing here is that all this happens during translation time and only static content is supported.

The include action <jsp:include> is almost similar to the include directive except for a few subtle differences. The include action is executed at request time as opposed to translation time. Thus instead of the content of the include file being included in the calling JSP, the output of the JSP is included or passed to the JSPWriter of the calling page. This allows us to include both static and dynamic content into the JSP page. Using the jsp action also allows you to explicitly pass parameters to the included page.

<jsp:include page="/index.jsp">
  <jsp:param name="name" value="sos" />
</jsp:include>
sree22_happy commented: good answers +2
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

If you want to access the value of input element "input[n]" try document.forms[formName].elements["input[n]"].value If you want the names of all the input elements, try:

function getInputNames(frm) {
  var arr = [];
  var elms = frm.getElementsByTagName("input");
  for(var i = 0, max = elms.length; i < max; ++i) {
    arr[i] = elms[i].name;
  }
  return(arr);
}

Read the Javascript FAQ for more details.

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

> That's an understatement!
And here I was, hoping to break it to them gently. ;-)

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

If you don't want server interaction, you can of course load the data from a local XML file and render it.

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

Never ever put business / backend logic in your JSP file. It's not what it was meant for. JSP is a presentation technology. Place your logic inside Servlets / EJB's and use DAO(Data Access Objects) to access your database. Reading the official J2EE tutorial would clear up things for you.

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

> Have you tried this site: http://www.roseindia.net/jsp/jsp.htm
I wouldn't trust that site. The content seems to be substandard. Maybe you should try out the official J2EE tutorial on Sun's site.

The next step in learning would be of course to grab hold of some decent titles than relying on online tutorials.

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

> I am a complete novice in java.
Then what you ought to do is start studying. J2EE 1.5 first cup and J2EE tutorials on the official Sun site should be sufficient at this point in time.

> I.m using oracle 9.1,tomcat 4.1 and java 1.4.1.
Why are you stuck with antiques when the latest version of Tomcat is 6 and JDK 5/6 stable version is very well available?

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

> It seems kludgy to me to change the attributes of the page.
> It is not at all elegant, and makes debugging harder.
> It reeks of self-modifying code.
Clearly you are ignorant of how professional Javascript code is written. Try to write something useful without *changing the attributes of the page* or writing *self modifying code* and you might just see the light. Not using the higher level abstractions provided by the language / API is just plain foolishness.

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

> What's wrong with using a simple button object that always calls the same function?
So what happens when tomorrow the requirement changes and you are told to add five more buttons dynamically? With the approach he is using, he would just have to invoke the function which renders a button five times.

But using your approach, it would mean adding five new blocks to the *ugly* if-else ladder not to mention brining hell to the maintenance programmer just because the logic which you used was not intuitive and obvious.

> Playing with the page attributes for this purpose seems to me like using a 10-ton hydraulic press to
> crack a peanut out of its shell.
Quite the opposite, it lends to a more elegant solution over a kludgey one.

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

> OK, job done.
Good to hear that. :-)

> From multiple option I'm able to select one and display full details for it, then return back.
Maybe you should consider posting the code in case if you have made any significant changes so that everyone can benefit from it.

> Thank you for your help ~s.o.s~
You are welcome.

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

Of course, running a while loop till I get what I want or picking up elements based on their tag name is how I normally do things. I just wanted to let the OP know where he had made a mistake.

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

The first method I posted is pretty simple, it just uses some basic array and string operations. Read the javascript String and Array object documentation and get back if you have any more queries.

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

This is because the value which you receive in the upload box is a Windows specific path. IE would obviously know how to interpret it but Mozilla won't.

To make this possible, you have to convert your windows path into a file resource which can be used by all browsers using the file protocol. Try this:

<!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 getData(srci) {
        srci = srci.replace(/\\/g, "/");    /* convert all \ to / */
        encodeURI(srci);    /* encode the URI to enable escaping */
        srci = "file://" + srci;
        alert("File resource at : " + srci);
        document.images[0].src = srci;  
    }
    </script>
</head>
<body>
    <form action="#">
        <input type="file" onchange="getData(this.value);">
        <br><br>
        <image src="#" alt="image">
    </form>
</body>
</html>

Keep in mind that there is no such thign mentioned in the specification which says that the path to the local resource can be successfully retrieved from the file select control and hence even the above trick might not work in some browsers like Opera.

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

You have got to realize that when we talk of XML, the whitespaces in your document matter and they get counted as a "#text" node. Assuming that xmlObj has the reference of the root node of the document, something like alert(xmlObj.childNodes[1].firstChild.nodeValue); should do the trick.

Here:

xmlObj -> <code> (Element)
childNodes[0] -> Whitespace (Text Node)
childNodes[1] -> <name> (Element)
firstChild -> sree (Text node)
nodeValue -> sree

Assuming the XML file is:

<?xml version="1.0" standalone="yes"?>
<code>
    <name>sree</name>
</code>
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Something like the below should do the trick:

function fuzzy(pwd) {
    if(!pwd || pwd.constructor == String || pwd.length < 3)
        return(pwd);
    var arr = pwd.split("");
    return(arr[0] + new Array(arr.length - 1).join('*') + arr[arr.length - 1]);
}
/* OR */
function fuzzy(pwd) {
    if(!pwd || pwd.constructor == String || pwd.length < 3)
        return(pwd);
    return(pwd.replace(/(.)(.*)(.)/, function(a, b, c, d) { 
           return(b+ c.replace(/./g, "*") + d); }));
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> looks like that I'm complicating my life with this xml and javascript exercise but now this
> problem get hold of me and I want to sort it

Frankly I don't know what exactly are you trying to achieve here. It seems more like the case of using the wrong tools for the job here. Why bother with the complications involved with rendering XML using XSL and that too involving a hefty amount of Javascript. Debugging in your case will be nothing short of hell.

Coming back to the problem I don't think this is correct:

<xsl:for-each select="propertyList/property">
	<xsl:if test="id/num = 1">
    	<xsl:value-of select="general/bedrooms"/>Bedrooms,<xsl:value-of select="general/type"/>, <xsl:value-of select="general/tenure"/>
    </xsl:if>
</xsl:for-each>

If you try the code which I have fixed, you will see that clicking on the "div" opens up a new page. From this we can conclude that the XSL processing of the XML document is one pass and if you need any sort of dynamic behavior *after* the rendering is complete, you would have to resort to some other means. What you have done just won't work.

Here is something which works (in a broken sense, of course):

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
<title>Preview</title>

<style type="text/css">
table { width:800px; border:solid; border-bottom-style:groove; border-width:thick; border-color:#DCF3F5;border-collapse:collapse; margin-top:20px;}
td {padding-top:8px; padding-bottom:8px; padding-left: 10px; padding-right: 10px;}
th {padding-top:8px; padding-bottom:8px; padding-left: 10px;}
td.just {text-align:justify;}
td.empty {padding-top:0px; padding-bottom:0px; padding-left: 0px; padding-right: 0px;}
</style>

<script type="text/javascript">
    var DOMCapable = !!document.getElementById;
    var propertyNum = null; …
peter_budo commented: Thank you for going trough the mess of my code and helping me find the solution. +7
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> That's what I have right now, just a gibberish phrase that came out of nowhere and won't go
> away: yaba yaba poi gatau.
Are you by any chance surrounded by kids who have decided to get back to you? ;-)

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

The functions which I just posted would just output the value which was passed to them. So if propertyNum was "single" followed by a number, it would show the same. Did you try to alert the value of propertyNum by using window.alert(propertyNum) before using it?

Like I said, you need to paste the XML file which you are using for me to reproduce the problems you are facing.

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

Welcome back Tayspen, long time no see. :-)

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

Do you want to output the value of propertyNum once the <p> element is clicked? If so, then try this:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
<title>Preview</title>
<script type="text/javascript">
    var DOMCapable = !!document.getElementById;
    var propertyNum = null;
    function show(property)
    {
        if(!DOMCapable) {
            return;
        }
        var grpStyle = document.getElementById("group").style;
        var sngStyle = document.getElementById("single").style;
        if(!grpStyle || !sngStyle) return;
        
        if(property == "group") {
            grpStyle.display = "block";
            grpStyle.visibility = "visible";
            sngStyle.display="none";
            sngStyle.visibility="hidden";
            propertyNum = "";
        } else {
            propertyNum = property;
            sngStyle.display = "block";
            sngStyle.visibility = "visible";
            grpStyle.display="none";
            grpStyle.visibility="hidden";					
		}
        var e = document.getElementById("txt");
        e.innerHTML = propertyNum;
        /*
        OR
        e.appendChild(document.createTextNode(String(propertyNum)));
        */
	}
</script>
</head>
<body>
<div id="group" onClick="show('single');">
<p style="cursor: pointer;">
    <xsl:attribute name="onclick">show('<xsl:value-of select='id/num'/>');</xsl:attribute>
    More details <xsl:value-of select='system/address1'/>
</p>
</div>
<div id="single" onclick="show('group');" style="display:none; visibility: hidden;">
<p id="propertyNum" name="propertyNum">Selected property ID is <span id="txt"></span></p>
</div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

Also it would be better if you create a style classes instead of changing individual style properties.

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

> Further, all previouse data needs to be saved, without using the database to store it.
Store the data in the user session using the server side language of your choice.

> I need to figure out how to make it so that, if the user skips a question
This can be done in two ways. One would be to use javascript for form validation and let the user know of any fields they have left out. Another one would be to do the entire thing server side.

The latter one is a much better approach since it would work even when the user has javascript disabled plus it allows you to have complete control over the data submitted. If you still decide to go with the first approach, there is always jsval.