Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!

Linda Xu

Ranch Hand
+ Follow
since Feb 14, 2000
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Linda Xu

The answer should be A and B.
C is unnecessary. D is exactly the wrong answer, redirect should happen BEFORE the response is committed
I am user Xerces 1.4 SAX parser. In my content handler, I need to print out the root element exactly the same as the original XML file I am parsing. Following is the code I used:
public void startElement(....) {
...
System.out.print("<"+localName);
for(int i=0; i<atts.getLength(), i++)
{
System.out.print(" " + atts.getName(i) + "=" + atts.getValue(i));
}
System.out.print(">");
....
}
When the root element have no namespace informaion, the print out looks perfect:
original:
<root ID="5">
printout from my code:
<root ID="5">
but, when I add some namespace information into the root element, the print out is not what I expected:
original:
<root
xmlns="http://myProject.myCompany.com/order";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="http://myProject.myCompany.com/order order.xsd"
ID="5">

now the print out is:
<root
xsi:schemaLocation="http://myProject.myCompany.com/order order.xsd"
ID="5">

here, I missed two lines from the original xml file. I tried to debug my code, and found that the xml=... and xml:xsi=... was not listed in the atts as attribute name/value pair. What's the reason? How to fix my problem?
Thanks for any comments.
Hi, All
I used a JTree in my project in which I have a DefaultTreeModel to store all the tree structure and a JTree show it on the screen. But for some reason, I want to hide some of the nodes from the user, but I don't want to remove them from the tree model because later on I still need to use them.
How can I hide some of the tree node from the user? Thanks for any information.
Linda
18 years ago
Hi, I have some weird Exception in my code, when I have this line:
int costScore = ((Integer)myHT.get("costScore")).intValue();
It gives me a run time exception: java.lang.Integer
To fix it, I just seperate it into two lines:
Integer tmpCostScore =(Integer)myHT.get("costScore");
int costScore = tmpCostScore.intValue();
then the Exception is gone. Why? Thanks for any input.
18 years ago
Hi, All
In all the articals talk about JDOM, I always found people saying " JDOM is light weighted, it doesn't require the entire document to be in memory." but at the same time "It provides a full document view with random access".
I really can't understand this. SAX is light weighted and takes less memory because it's event driven, that't also the reason we can't "random access" the elements in the XML file.
DOM mapping the whole XML file into a tree hierarchy so we can have random access but that will take a lot of memory if the XML file is big. That's also understandable because we put all the data in the XML into memory.
To me, JDOM document is very similar to a DOM document, it's collected all the information in the XML file and built into a tree hierarchy, so we can have random access but SHOULD take a lot of memory. I know there must be some thing I misunderstood here, but what is it?
Any one can explain this to me? Or I need some example to "convince" me, say, build a JDOM document and a DOM document from the same XML file, then compare their size, but how to implement this exprement.
Thanks for any information. It's really haunting me.
Hi, All
I am trying to use the taglib custom action to replace the java code in my JSP files.
For example, originally I have:
<%
Vector myVec;
...
for(int i=0; i<myVec.size(); i++)
{ myObj = myVec.elementAt(i);
%>
<%= myObj.toString() %>
<%
}
%>
in my JSP file, now I can easily replace it by:
<ora:loop name="myVec" id="myObj" class="java.lang.String">
the obj is <%= myObj %>
</ora:loop>
The JSP using taglib will be easier to write and maintain than using embedded java code.
But, here I have a side effect: When use embedded java code, I have more control on the positions to loop through, e.g. I want to loop from the third element at the left until the third element at the right side of the vector, I can easily change the java code to:
...
for(int i=3; i< myVec.size()-2; i++)
...
But how to achieve this using the taglib custom action?
18 years ago
When I run my project (java servlet / jsp ) on tomcat, I sometimes have this error message:
java.net.SocketException:Connection aborted by peer:socket write error
at Java.net.SocketOutputstream.SocketWrite
...
What's this error? How does it impact my project? How can I handle it?
Thanks!
18 years ago
Hi,
I have a JTree on the GUI, for some reason I want to hide all the handles(which is shown at the left of a node when it have child).
In the Java API, there is a method called
setShowRootHandles(false)
But this will only hide the handles at the topmost level, how about the lower levels? I want to hide them also.
Thanks!
19 years ago
Hi,
I have a JTree on my GUI, for some reason, each time when a new node added / deleted to/from the tree, I want the whole tree been expanded, that means all nodes in the tree are visible.
I found a method
public void scrollPathToVisible(TreePath path)
in class JTree, but this method only expand one path, all the others are collasped.
Is there any method can expand the whole tree?
Thanks!
19 years ago
Hi,
I have a JTree in the GUI, in the tree I have some nodes which we don't want it to expand, even the user double click to expand it, we still want to hide all the children of that node? How can I do this?
Thanks!
19 years ago
Hi, All
I am a java programmer.
In my job, I found most of the bugs(except the logic mistakes in the design) are very common, for example: missing a parenthesis, cast an object into another uncompatible type, ...
So I want to make a check list for java programmers, in which I lisk all the common mistakes, so when we coding we can try to avoid them, and when we have some compiling / running time error, we can also use this check list help us to find the bug.
Followed is my check list, please give me any suggestions of yours.
Java Programmer Check List
1. match the parenthesis
2. initialize the variables
3. use �equals� to compare two objects
use �==� to compare two primitive variables
4. every line ended by ;
5. the instance variable have the scope as �private�
6. use constant to avoid the magic number
7. include all the required library
8. catch the exception
9. deep copy of an object (clone)
10. cast an object to another type
11. have a return command if the method have some return type.
12. flush and close a file after write data into it
13. use & and && correctly

Thanks!
19 years ago
Hi, All
I am a java programmer.
In my job, I found most of the bugs(except the logic mistakes in the design) are very common, for example: missing a parenthesis, cast an object into another uncompatible type, ...
So I want to make a check list for java programmers, in which I lisk all the common mistakes, so when we coding we can try to avoid them, and when we have some compiling / running time error, we can also use this check list help us to find the bug.
Followed is my check list, please give me any suggestions of yours.
Java Programmer Check List
1.match the parenthesis
2.initialize the variables
3. use �equals� to compare two objects
use �==� to compare two primitive variables
4.every line ended by ;
5.the instance variable have the scope as �private�
6.use constant to avoid the magic number
7.include all the required library
8.catch the exception
9.deep copy of an object (clone)
10.cast an object to another type
11.have a return command if the method have some return type.
12.flush and close a file after write data into it
13.use & and && correctly

Thanks!
19 years ago
Hi,
I have an applet in which I call getParameter("parameterName") to retrieve the parameter.
In my HTML file, I have the parameter set like this:
<PARAM NAME="parameterName" VALUE="blah">
The applet works well on IE, but when I run it on Netscape 4.7, the parameter I got is null.
I checked on the web, it looks that many people also got this problem, but I didn't see any good solution. Only one guy said if the characterset in Netscape is set to any thing other than "Western" (e.g. Chinese, or Japanese), the getParameter will return a null, but my characterset already set to Western(ISO-8859-1), I am really lost.
Thanks for any information.
19 years ago
I think the problem is in your SQL query, to my guess your "name" is a string, so you need a ' to quote it, to write this in Java, you need a \ to escape, like"
query = "insert into tableName(name) values(\'userName\');";
Wish this to be helpful to you.
19 years ago
I got an error message when I want to run a servlet in JBuilder 5 which have Tomcat 3.2 built in:
FATAL:java.net.BindException: Address in use: JVM_Bind
What's this error? How to solve it?
Thx!
19 years ago