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

> every serializable class needs a static final long "serialVersionUID"
> field

Yes, but static fields as a rule are not serialized by default. serialVersionUID is a special static field which is an indication to the serialization mechanism that 'persist the given instance with this version'. Even if a serialVersionUID is not provided, the serialization mechanism generates one based on the class structure / object hash code. Hence it would be a bit misleading stating that static fields are persisted when talking about serialVersionUID.

As long as no changes are made to the class, there is as such no problem ser/deser an object to persistent storage and retrieving from one with a default generated serialVersionUID. The problem arises when you make structural changes to the class which should in no way be treated as a different version [e.g. adding a method which has got nothing to do with ser/deser state of a class instance]. In this case, the serialization fails if a serialVersionUID field was not provided when defining the class.

So to cut long story short, don't think of serialVersionUID as a *static* variable stored to a persistent storage but as an indication to the serialization mechanism to *not* generate a default version number but use the one provided. To support this theory, every field persisted shows up in the serialized file i.e. if an object having instance variables "gogo" and "gaga" are persisted, the serialization file would show "gogo" and "gaga" with some other …

stephen84s commented: Cool, Great Info !! +5
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> any variable not declared as "transient" (even static variables)
> would be serialized and their state stored.

No, not really.

public class StaticTester implements Serializable {

  public static int gaga = 1;

  private int gogo;

  public static void main(String[] args) throws Exception {
    doTest();
  }
  
  private static void doTest() throws Exception {
    StaticTester t = new StaticTester();
    ObjectOutputStream oos = null;
    ObjectInputStream ois = null;
    File f = new File("o.ser");
    System.out.println("Static field before ser: " + StaticTester.gaga);
    try {
      oos = new ObjectOutputStream(new FileOutputStream(f));
      oos.writeObject(t);
    } finally {
      oos.flush();
      oos.close();
    }
    StaticTester.gaga = 999;
    System.out.println("Changed static field after ser: " + StaticTester.gaga);
    try {
      ois = new ObjectInputStream(new FileInputStream(f));
      t = (StaticTester)ois.readObject();
    } finally {
      ois.close();
    }
    System.out.println("Static field after deser: " + StaticTester.gaga);
  }

}
/*
OUTPUT:
[java] Static field before ser: 1
[java] Changed static field after ser: 999
[java] Static field after deser: 999
*/
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Secondly, you can use it on any element in your document, not
> just the root node.

Agreed; looking up anchor elements nested inside a given node would be one of the valid reasons for using getElementsByTagName().

> and is not very process-intensive at all

The reason I said it was a bit processing intensive is because the links collections of the document element is populated when the DOM is created out of the markup but getElementsByTagName requires a traversal through the entire DOM tree to collect all those anchor elements. So, even though it isn't processing intensive in an absolute sense, when compared to document.links, it surely looks so.

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

If that's your requirement then you need to change your original code which is as of now setting the onmouseover property of A elements and not LI elements in which the A elements are nested i.e. instead of thisLink, the element in consideration should be thisLink.parentNode.

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

A pure CSS solution:

<!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">
    <title>Example</title>
    <style type="text/css">
      li a {
        background-color: #abc;
      }
      li a:hover {
        background-color: #def;
      }
    </style>
  </head>
  <body id="bdy">
    <div>
    <ul>
      <li><a href="http://www.google.co.in/">Google</a></li>
    </ul>
    </div>
  </body>
</html>
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I need a bit more background on the requirement/problem here as in what is the source of the XML you are talking about? Is is shipped over the network using an async call in the form of AJAX or read from an external file? Also posting some sample code which others can hack on and reproduce your problem might just help in faster resolution since "works differently" is kinda difficult to pinpoint given there is no context established in the form of a code snippet.

Also, given that XMLSerializer is specific to Gecko based browsers [not a standard], reading the API or asking in the Mozilla forums seems to be your best bet.

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

Maybe posting the *exact* code which is causing problems in your case would help in faster resolution of the issue at hand. And please use CODE tags when posting code to increase your chances of getting a reply since reading unindented code is a pain in the neck. Read the forum announcements to learn more about CODE tags.

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

Because selectedIndex can't be a alphabet; it has to be numeric; more specifically long.

It would be better if you just passed in `this' and got the value selected using:

function showSomething(elem) {
  var val = elem.options[elem.selectedIndex].value;
  // process the value
}

// in your markup
<select id="choice" onchange="showReg(this);" size="4">

Make sure the intrinsic event handlers are in all lowercase as mentioned in the specification i.e. onchange instead of onChange . Also make it a practice to assign a `name' to all form elements because AFAIK values of elements without a name aren't submitted.

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

Whenever possible, you should always use the W3C
'document.getElements...' methods rather than collections such as
document.links, .forms or .images

links is a standard property of the document DOM element. It would be interesting to know the reasons of preferring the long winded and probably expensive document.getElementsByTagName() route.

@xander85:
AFAICR, there is a pure CSS solution which perfectly fits your scenario. I can't think of a better solution than letting the rendering engine do all the heavy lifting for you rather than you doing it yourself. The CSS solution has the advantage of working even when Javascript is disabled. Maybe something like:

li a {
  background-color: #999;
}
li a:hover {
  background-color: #333;
}
xander85 commented: I should have thought of that, THANKS! +2
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The problem you are trying to solve here has already been addressed by AOP i.e. addressing cross cutting concerns. Read this.

Sifting through that big code would be quite a herculean task; I would advice you to use an IDE like Eclipse/Netbeans for debugging your application. Also I hope you realize that the logic you so painstakingly wrote would break as soon as someone decides to format the code in a different way?

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

> Is it possible to pass a large parameters with the POST request ?

Ideally yes, since I find no mention of a limit in the HTTP specification. Practically, it depends on both the browser/user agent and the server accepting the request, which again should be enough for your needs. Are you facing any problems as of now?

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

Bold is considered shouting; please keep formatting to a minimum. In case you are quoting a article, consider using [quote][/quote] tags.

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

The warnings are because the specification uses all lowercase convention when specifying intrinsic event handlers; i.e. onchange in favor of onChange.

Since this is some library specific issue, your best bet is to run this application in Firefox and use the Firefox Error console or the addon Firebug to trace Javascript errors.

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

Since you are writing out textual content, you should use a Writer instead of dealing with raw bytes and the like. What exactly is your requirement? If you don't need to edit the file at a random location, RandomAccessFile isn't even required. If the text is overwriting the original text, it means you are not properly aligning your file pointer.

Look into the methods getFilePointer() for saving the previous write location and seek() to move to that location. Without a working compilable code, helping you out will be difficult.

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

Is it really necessary to use a RandomAccessFile? Using a FileWriter in append mode should do the trick.

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

A constructor is a special construct of the Java programming language which can be loosely thought of as a method with the same name as that of the class for which the constructor is meant with *no* return type and which will *always* be invoked when an instance creation is requested.

A no-arg constructor is a constructor which doesn't take any arguments.

public class Person {
  private String name;

  // no-arg constructor
  public Person() {
    this.name = "default";
  }

  // a constructor with one argument, name
  public Person(String name) {
    this.name = name;
  }
}

In case you fail to provide a constructor, a `default' constructor is automatically provided to you which *always* will be a no-arg constructor.

I would recommend you first need to read the basic Java tutorial hosted on Sun and those posted in the stickies at the top of this forum since all these questions are already answered there. If you really want to learn, your questions should *not* be of the form "What is XXX?" rather "Given that XXX is YYY, I really don't how ZZZ fits the picture".

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

If your project was set up in Eclipse, the "Restore from Local History" option might work out for you; it's worth a try.

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

There is no such thing as AJAX variable. In case if you want to persist a Javascript variables' value to a persistent store by making an async request to the server, you can just append the value in consideration to the query string like:

http://your.server/?value=yourValue

which would be read at the server (using a server side environment of your choice) and then persisted.

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

> How can I achieve this ?

In case of a GET request, the data is embedded in the query string while in case of POST request, it is passed as a argument to the send method of XHR object. Read this.

> Is POST method can read a large string from any html element
> using AJAX ?

You seem pretty confused here; what exactly do you mean by read a string from HTML element using AJAX?

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

The given JSON can be simplified as:

var json = [
  {"zip" : "27603", "city" : "Raleigh", "state" : "NC"},
  {"zip" : "25071", "city" : "Elkview", "state" : "WV"}
];
for(var i = json.length - 1; i >= 0; --i) {
  var o = json[i];
  var zip = o.zip;
  var city = o.city;
  var state = o.state;
  alert(zip + " " + city + " " + state);  
}

If using your original JSON representation:

var json = {"results": [
  { "zip" : "27603", "city" : "Raleigh", "state" : "NC"},
  { "zip" : "25071", "city" : "Elkview", "state" : "WV"},
  ]
};
var arr = json.results;
if(!arr) return;
for(var i = arr.length - 1; i >= 0; --i) {
  var o = arr[i];
  var zip = o.zip;
  var city = o.city;
  var state = o.state;
  alert(zip + " " + city + " " + state);  
}

You can wrap this entire thing in a function which will analyze the JSON string fetched, iterate over all the city names and execute a given logic accordingly.
To verify the validity of your JSON, use JSONLint.

Also, I would recommend using the parseJSON method found in json.js, instead of eval .

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

> But this certainly requires an API defined at their end

Not certainly, screen scraping is always an option and which I guess is what the OP is looking for in this case given that it's a school project.

> it is difficult to find the information I need in the source code

As long as you don't abuse the service, XQuery and some other options can make your screen scraping a bit easier.

This involves a two step process:

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

A second season is welcome as long as they don't plan on ruining it like the first one.

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

Indeed; the entire point of the exercise was to make use of basic math tricks to come up with a compact solution and to exercise the basics of OOP.

Create a class which bears the responsibility of accepting a number and maintaining the state of which range appears how many times.

Like previously mentioned, use an array to maintain the occurrence count and calculate the range based on the number inputted rather than having thousands of conditionals.

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

> I don't think that anyone in academics would agree with such a
> broad statement.

...something which I was expecting all along. ;-)

JFTR, how many good java programmers have you seen who are not good with the tools they work? And how many programmers have you seen who struggle with the basics of Java programming language but still are focused on learning the tools? As for me, none of the former and a lot of latter.

> but knowing how to properly use your resources is probably just
> as important.

From a practical standpoint, anyone can learn every feature in Eclipse related to Java development in a day; so yes, tools are important but not something which need focus, you just work in them and their usage becomes pretty much second nature. This is something which can't be said about understanding the language basics.

But it seems almost everyone in this thread agrees that basics come first, tools second, so now, back to helping out the OP. :-)

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

> whenever you access a method, it gives you a summary of what the
> method does, as given in the API

...so do the online java docs. But in most of the cases we end up with a bunch of CTRL + SPACE programmers who find it too troublesome to even remember the method signatures of the most commonly used methods out there.

As someone who earns from programming, I find such tools to be really useful in boosting ones' productivity and getting the job at hand done faster, it can't be denied that knowing the basics of the language you develop in of prime importance. I am pretty sure none of us would want to hire someone who is completely lost without an IDE; after all, it's a Java developer we are looking for and not just a Eclipse/Netbeans/IntelliJ user.

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

Simply put, the list returned by the `findFlights' method seems to return a list of Object arrays rather than a list of FlightItenary.

Don't mix and match type safe code with non-type safe code; either use generics all the way through or don't use it at all [not recommended]. Try to debug the `findFlights' to see what exactly is it returning.

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

> I want to prevent visitors from being able to type anything in this
> field altogether

This isn't a JSP question but relates more to the markup language used; I guess HTML here. Use the 'readonly' attribute of the INPUT element:

<input name="txtInfo" value="some-info" readonly="readonly">

If you don't want this field to be submitted on form submission, use the 'disabled' attribute instead.

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

> although I have this "izraz.txt" file in the correct location

If that were the case, the said exception won't be thrown by the Java runtime. The solution to this issue depends on how you are executing your program. Are you using an IDE, or is it a command line invocation of `java' or are you using any build tool like Ant?

A simple way of knowing your current working directory is to create a blank file with some unique name [e.g. java-sucks.txt] using your PostFix program and search your file system for that file; the location where you file was created is where you should have your `izraz.txt'.

BTW, you still have parsing logic in main() and dynamic string creation is better done using StringBuilder than using += repeatedly inside a loop.

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

> one byte of storage for each character

The char data type is a single 16-bit Unicode character. It has a minimum value of '\u0000' (or 0) and a maximum value of '\uffff' (or 65,535 inclusive). Read me.

Why is it that you are required to come up with such a hack just to extract some data? Where is the data coming from? Doesn't every field have some fixed width? Maybe explaining a bit about what you are trying to achieve here rather than how you are trying to achieve it might fetch you some good answers.

And like I have previously mentioned, don't go on confusing bytes and characters; a string is just a sequence of unicode characters. So if you have a string "abc010101xyz", the "0" there is just a character, not an integer, not a binary digit. Just come up with a specification of how your data will be formatted and process the string as a sequence of unicode characters rather than bytes and bits.

stephen84s commented: Very well said +5
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You ain't doing it right. Maybe this would help.

srs_grp commented: It was really helpful!! +1
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Merry Christmas to all the members of Daniweb; hope Santa gives you all the gifts you ever wished for. ;-)

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

> Ouran is good.

Oh yes, I have seen this series, pretty good end; the setting reminds me a bit of Special A. But I would rather prefer a female harem. ;-)

> I'd probably say Shuffle! is decent too if pressed.

Shuffle! might be one of those animes out there which have got extreme ratings; those you like it love it and those who dislike it hate it.

> I'm thinking it'll be more of a darker, angsty Otoboku.

Let's see, it seems to be worth the wait. :-)

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

> I'm working on a program that needs to store user info, then can
> retrieve it

In short, your program needs some sort of persistence mechanism. You have a few options:
- Object persistence [search the web for java serialization API]
- File persistence [saving the data in the form of CSVs]
- Database persistence which again comes in two flavors:
--- Serverless databases like SQLite, excellent for standalong apps
--- Server databases like Oracle recommended for n-tier distributed applications.

Take your pick.

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

> It's hard to come up with a good harem series.

AFAICR, I have heard you say the same thing in IRC once. Does there even exist a harem series which you like or are you still waiting for an ideal one to come along? ;-)

> As a Maria-sama ga Miteru fan, I'll have to disagree with you.

Hmm..romance genre, interesting. But still Natsume has elements of uniqueness IMO not found in any anime out there.

> My big hope for the new year's anime is Maria Holic.

I, My, Me - Strawberry Eggs revamped?

> If you watch enough, you pick up on parts of the language.

Yes, I have started to see that as proved by my feeble attempts at speaking Japanese monosyllables in IRC. :-)

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

I am sure PHP has some sort of MVC architecture implementation wherein the controller handles the requests and delegates it to an appropriate entity.

// Here /operations is mapped to a PHP file which acts as a 
// controller and performs the delegation activity based on
// the operation requested, here, find-provinces
xmlHttp.open("GET", "/operations/find-provinces", true);
xmlHttp.send(null);

Maybe posting this PHP related query in the PHP sub-forum might bring out some good responses since this seems more like a server-side url mapping/configuration issue.

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

@ben98
I am pretty sure the thread starter must have found one by now, so why did you have to resurrect this relic ?

Just for the record, thread resurrection is allowed as long as the content posted is helpful in one form or the other. It might so happen that the bumped post ends up providing a lot more information.

Previously the moderators used to close the threads which were bumped which ended up people not being able to reply even if they had a better answer. Hence the new stance of dealing with bumped threads.

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

It's OK to reply in this thread; it's not as if you are replying only to promote that provider, it would be more like an answer to the question asked.

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

Maybe something like [untested]:

var reg = /(<span[^/>]+)\/>/gi;
var str = "<span id='d'/><div id='3'>d</div>" +
          "<span id='j' style='blah: 10px'/>";
var a = str.replace(reg, "$1><\/span>");
alert(a);

But this would mean looking away from the actual problem; the problem here is that SPAN HTML tags need to have a ending tag. What is xmlParser here? How come xmlParser returns an invalid span tag; can't it be fixed to return proper spans?

And BTW, this isn't a Firefox problem, it is actually doing what it should do. Since SPAN tags need to have content, the /> is ignored and <span id="something" /> is treated as the start of a SPAN tag.

IMO, the solution you are seeking seems more like a hack.

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

Instead of private messaging the solution, you can attach your project here or post a link to an external site if you have your project hosted somewhere else [e.g. sourceforge] so that others can benefit from it.

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

Hi,

I am kind of new to JSP. I am having trouble outputing something:

<%=request.getParameter("UserName")%>

now if UserName has special Characters (i.e &hearts; ) it does not get outputed corectly. that code above should display the heart symbol, but instead I get something like this: âÂ...

is there some kind of converstion function I can use?

Thanks.

The document encoding doesn't seem to be a problem here since &hearts; is a valid HTML entity and its rendering doesn't seem to be dependent on the document encoding. The specification says: "To support these entities, user agents may support full [ISO10646] or use other means".

How exactly are you persisting the user name to your database i.e. where exactly is the user name coming from? Have you tried to print out the user name before persisting it? Is it the same as inputted by the user? Does directly writing out "&hearts;" works?

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

Multi posted in the Javascript forum.

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

> can u please help me find a way to start a new process each time i
> open a new window?

AFAIK, you can't. You don't get to decide how a request for a link to be opened in a new window is treated by the browser; it can open in a new tab in case of tabbed browsers or in a separate browser process in case of browsers which don't support tabs.

This is mostly a server side / server configuration issue and largely depends on the technique used for session persistence and the server environment used.

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

> +1 what?

Maybe James' way of saying that he agrees with the above post? ;-)

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

The twoDArray in your case is just an array of size 10 with each slot referring to a integer array i.e. two dimensional arrays in Java are just an array of arrays. Hence you can either use twoDArray[3] = oneDArray; or System.arraycopy if you don't want modifications in the original oneDArray to be reflected in twoDArray. Also read this.

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

The view presented by the Java programming language for anything networking related is too high level/abstract [which is a good thing from productivity POV].

Writing networking code in C is probably the best way of hacking around with the core networking protocols and to see how the things really work; something which has been on my TODO list for quite some time. :-)

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

> Are there any sites with English version?

These anime when originally aired in Japan have Japanese voice over and known as RAWS. There are many fan subbing groups out there which add English subtitles to these raw episodes which are known as SUBS. There are also a few dubbing groups out there who dub the raw episodes providing a English voice over.

AFAIK, dubbed anime is far difficult to get than subbed anime. You can get almost all subbed anime out there at Animesuki or at CrunchyRoll and YouTube for online viewing.

Watching subbed anime might take a while to get used to but it's the most convenient of get hold of most of the anime series out there. BTW, even I don't know Japanese and I am an avid anime viewer thanks to subbed anime. :-)

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

Saying that 'XXX is not possible in Java' is pretty misleading IMO.

Is I/O and Networking possible in Java? You might say yes, there are packages like java.io.* and java.net.* for it. But is it really possible in *java*? Both I/O and Networking libraries which are part of the standard libraries at their core make JNI calls and are platform specific since the way I/O is performed is OS/platform specific. So as long as you have the proper JNI code in place along with dynamic libraries for your target platforms, almost anything is possible in Java. The same argument applies to 'Java only works at Application/Transport layer'.

But to answer the question, yes, a ping utiilty can't be written using the standard Java libraries, since AFAIK, Java doesn't allow creation of raw sockets which are needed to send ICMP packets.

Ping requires ICMP packets. These packets can only be created via a socket of the SOCK_RAW type. Currently, Java only allows SOCK_STREAM (TCP) and SOCK_DGRAM (UDP) sockets. It seems unlikely that this will be added very soon, since many Unix versions only allow SOCK_RAW sockets to be created by root, and winsock does not address ICMP packets (win32 includes an unsupported and undocumented ICMP.DLL).

stephen84s commented: Informative, Discovered another new thing from your post +4
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Yes, I think so, and so would Joey. :-)

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

Any exception in Java comes with a stack trace. Try to read the entire exception trace and see on which line things are going wrong. If you are using an IDE like Eclipse, use the debugging feature to inspect the values at run time. If you are using a normal text editor, look into the command line debugger JDB. BTW, have you allocated memory to the Member array box?

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

If you don't want to, you are under no obligation to reply to his PM's or entertain him on a personal level just because you are a moderator. If you are troubled by his PM's, bring this up with a super-mod or administrator as PM's with objectionable contents fall under the rules of infrationable offense.

We already have a Daniweb Community Feedback forum for such kind of things; ask him to bring up the issue here.