John Daniel

Greenhorn
+ Follow
since Mar 27, 2005
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 John Daniel

Thank you all for taking the time to answer my little query.
After reading K&B's excellent book twice, I thought I had a firm understanding of protected access. Now that I'm in Mughal's book, however, I realize how wrong I was. I've pasted part of Mughal's question 4.18 below. What I don't understand is why does (3) compile and (7) doesn't. I ran the compile myself to see if Professor Mughal is correct, and of course, he is. (7) really doesn't compile. I just don't understand why. I appreciate any insights anyone can provide.

Question 4.18:
// Filename: A.java
package packageA;

public class A {
protected int pf;
}
--------------------------------------------
// Filename: B.java
package packageB;
import packageA.A;

public class B extends A {
void action(A obj1, B obj2, C obj3) {
pf = 10; // (1)
// obj1.pf = 10; // (2)
obj2.pf = 10; // (3)
obj3.pf = 10; // (4)
}
}

class C extends B {
void action(A obj1, B obj2, C obj3) {
pf = 10; // (5)
// obj1.pf = 10; // (6)
obj2.pf = 10; // (7) **Compiler Error**
obj3.pf = 10; // (8)
}
}

Thank you,
John Daniel
Thank you for your prompt and informational reply. John
Chapter 6 of K&B talks about overriding the write/readObject methods for serialization with private methods of the same name. I have two questions about that.
1) Why are the overridding methods private? I didn't think you could override a method with a private one.
2) When calling the original methods, why do you have to use defaultWrite/ReadObject? What's wrong with using super?
I'm sure I'm missing something; I just don't know what.

Thank you for your time.
John Daniel,
Carrollton, Texas
Thank you, Deepak, for your prompt response. Just to be clear, are you suggesting to not buy a 1.6 book and instead learn the 1.6 enhancements in some online tutorial? Are the 1.6 enhancements that insignificant that they can be learned online? If so, that sounds like a good way to save $30+ to me. Do you have a recommended 1.6 enhancements tutorial that you are willing to share the link to?

Thank you,
John
I have a copy of Kathy and Bert's 1.5 certification book, and I'm very pleased with it. However, we're looking into rolling out Java 1.6 at work, so I've decided to invest in a 1.6 certification book to use in preparation for the 1.6 SCJP test. Even though K&B have a 1.6 book out, I'm looking at buying one of their competitors books, so that I can learn the material from a different perspective. The most cited "other" book is one by Khalid Mughal, which lists on Amazon.com for a pricey $42.89 and is a mammoth 1088 pages. But there is also a 1.6 certification book listed on Amazon for $31.49 (same price as K&B's book) which is written by Richard Raposa and is a more manageable 578 pages. Unfortunately, I can't find any reviews for it. Have any JavaRanch members read Raposa's 1.6 book that would care to comment on it?

Thank you,
John
Sorry, I submitted my response before I was ready.

Anyway, in my JSP, I added:

<script language="JavaScript">
function displayWait() {
var waitDiv = document.getElementById("wait");
waitDiv.style.display = "inline";
return true;
}
</script>
. . .
<form name="ResetPassword" action="../servlet/whatever"
method="post" onSubmit="return(displayWait());">
. . .
<div class="wait" id="wait">
Your request is being processed, please be patient.
</div>
. . .

And in my CSS file, I added:

div.wait {
width: 39%;
padding: 4px;
display: none;
margin-left: 40px;
color: green;
background-color: white;
}


So what the JavaScript code is doing is simply changing the default display attribute from "none" (don't display) to "inline" (do display).

Hopefully, someone will find this helpful.
11 years ago
Due to the ever shifting priorites from management, I haven't been able to work on this issue again until now. Anyway, this week I started working again on displaying a "please wait" message using Bear Bibeault's advise of a simply displaying a hidden message.

However, not being familiar with JavaScript, I had a hard time figuring out how to do that. So in case someone does a search on this topic, and wants to know how to display a "please wait" message, here's is how I got it to work.

In your JSP, add the following:
<script language="JavaScript">
function displayWait() {
var waitDiv = document.getElementById("wait");
waitDiv.style.display = "inline";
var msgDiv = document.getElementById("message");
msgDiv.style.display = "none";
return true;
}
11 years ago
Thank you, that's what I wanted to know. jd
11 years ago
I'm a Java newbie writing a small web application. I've been reading K&B's HF Servlet and JSP book at night in my attempt to catch up on the technology. Anyway in chapter 5, Kathy makes it very clear that servlet instance variables are not thread-safe. I understand that. But what I'm not clear on is what about instance variables of new'ed POJ classes? If my servlet instantiates a class containing instance variables, are those instance variables thread-safe? jd
11 years ago
I know about the trim string method which will remove trailing spaces from a string. What I want to know is there an easy way to do the reverse, that is add spaces to the end of a string so that it is a minimum length? The best I've been able to come up with is the following for loop.

for (int i = myStr.length(); i < MIN_LEN; i++) {
myStr += " ";
}

Is there a more straight forward way to perform this function?
11 years ago
I've been able to create a small three screen web application using Murach's Java Servlets and JSPs book with only the usual number of issues. Now, however, I need to convert my application into a "war" file. Unfortunately, war files are not in the book. Could someone please give me the "war files for dummies" summary of how to create a deploy-able war file?
My servlet needs to send a message, via MQ, to another platform and wait for a response. This process may take several minutes. Is it possible to display to the user a pop-up message telling them that their request is being processed and to wait? And then when the request is finished, remove the pop-up, and display a completion message?

Thank you,
John Daniel
11 years ago
Thank you guys for all of your advise.

Stan, I do have some questions about those CSV files you transferred between PC's and mainframe Cobol. Did you let TCPIP do the ASCII/EBDIC conversion? Did you encounter any IP ASCII/EBDIC conversion issues? Do you know if IP ASCII/EBDIC conversion is all or nothing, or can you specify which fields to convert, and which fields to leave alone?

Also, with CSV files being so common, does Java have any methods to help with the formatting and unformatting of them? jd
12 years ago
Thank you Stuart and Stan for replying to my post. I ran a little test using serialization and I was able to read and write records, or I guess I should say objects, to a file. However, apparently, serialization is only for Java programs reading Java produced files because Java inserted some addition characters into the file. The source of the master file is on the mainframe host, so it won't be in the serialization format that Java expects.

Neither of you guys said anything about data structures and neither did Kathy and Herb in their books. I assume that means that Java just doesn't support structures. It that right? That means I'll have to take a different approach. Let me know what you think about this?

1) On the mainframe, split the file into two files. One with all convertable fields in display format and the second one with the remaining binary fields.
2) Download the first file in character format, so that the EBDIC to ASCII conversion takes place, and download the second file in binary format, so that no EBDIC to ASCII conversion is performed.
3) Then in a Unix Java program, read a record from the first file via the readLine method, and read the appropiate number of matching fields from the second file via the readInt and readDouble methods.
4) Save these fields in a Java class, and write the file out to dasd with the serialization methods mentioned earlier, so that the file can be proccessed later with other Java programs.

Thanks, jd
12 years ago