Roger Chan

Ranch Hand
+ Follow
since Nov 13, 2001
Merit badge: grant badges
For More
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 Roger Chan

I am writing a small html and a JSP page. The jsp page is trying to find out if the referer page is
numLimit.html.
HTML page (numLimit.html)
<html>
<head>
</head>
<body>
<form method="GET" action="test.jsp" name="form1">
<input type="submit" value="Submit" name="sButton">
<input type="hidden" name="previousPage" value="9">
</form>
</body>
</html>
============
JSP page (test.jsp)
<html>
<head></head>
<body>
<% if (request.getParameter("previousPage"
== "9")%>
got it!!!
<% else %>
nope!
</body>
</html>
However, the JSP page always prints out "nope" even though I am expecting "got it!"
Do anybody know why?
Thanks.
21 years ago
JSP
Hi Budi,
I found out that you have written a couple books in .NET as well. What is your opinion about the .NET and J2EE development platform? What are the strength and weakness of each framework? Do you have any preferences?
Thanks,
Roger

Originally posted by Sandeep Lodhia:
What do u mean by 'high quality' ???
EJb O'reilly Publication is available online at :
http://phatdaddy.dyns.net:8080/Oreilly/Java2/ebeans/index.htm


I mean something precise and to the point that is helpful for preparing technical interview. Thanks.
Are you any high quality EJB tutorial available on the web?
Thanks.
This Forum FAQ had mentioned Servlets and JSP fundamentals tutorals from Sun's website? How good are they? Are there any other high quality Java web component tutorials?
Thanks
Do anybody know about some groups that are doing voluntary software development project using Microsoft technologies? I mean... programmers spend their leisure time to do projects for free. I know a Dallas Java User group is doing that.
Thanks
22 years ago
Hi Charles,
Congratulation!!!
Do you think the SCEA exam is too difficult to people without software architecture design experience? I just cleared my SCPJ exam. My next step will be to take the Certified Web Component Developer exam. I am also very interested in learning EJB, UML and architecture design.
What do you think?
Thanks
What is the correct way of specifying the end of a file when using RandomAccessFile class?

or

I found conflicting information from two sources. That is why I want to confirm.
Thanks
Hi folks,
What is the correct way of specifying the end of a file when using RandomAccessFile class?

or

I found two conflicting information from two sources. That is why I want to confirm.
Thanks
22 years ago


<code><pre>
class Pet {}
class Dog extends Pet {}
class Cat extends Pet {}
public class ExtendsTest{
public static void main(String args[])
{
Pet generic = new Pet();
Dog fido = new Dog();
Cat felix = new Cat();
// insert statement here
}
}
(a) generic=fido;
(b) felix=generic;
(c) fido=(Dog)generic;
(d) felix=(Cat)fido;
(e) fido=(Pet)fido;
</pre>
</code>
QUOTE]
Hi Jim,
Thanks for your explanation. Concrete example does make things a lot easier to understand.
Roger

Which statements, when inserted at line 1, will cause a runtime exception ?

(a) b=b1;
(b) b2=b;
(c) b1=(B1)b;
(d) b2=(B2)b1;
(e) b1=(B)b1;
Explanation for (d): It will not compile because b1 can never refer to an object of class B2
Is this because what b1 and b2 refer to have no inheritance relationship?
Explanation for (e): The following will compile:
b1=(B1)(B)b1;
The above statment upcasts and then downcasts back to the original reference type. Is it doing anything at all?
Thanks

I wonder why the last statment will cause run-time error, ClassCastException. With the explicit casting before object reference a, downcasting should be allowed.
Thanks
class TestClass
{
public static void main(String args[])
{
String str1 = "str1";
String str2 = "str2";
String str3 = str1;
str1 = str1.concat(str2);

System.out.println( str1);
System.out.println( str3);
}
}
As String class is immutable, a new object is created when the content of the String instance changes. But in the above code snippet, str1 concatenate with str2. The result string is assigned backed to str1(same intance name). Will this str1 be a new object or still be the original str1 which contains "str1"?
Thanks

class CorbaComponent
{
String ior;
CorbaComponent(){ startUp("IOR"); }
void startUp(String s){ ior = s; }
void print(){ System.out.println(ior); }
}
class OrderManager extends CorbaComponent
{
OrderManager(){ }
void startUp(String s){ ior = getIORFromURL(s); }
String getIORFromURL(String s){ return "URL://"+s; }
}
public class Application
{
public static void main(String args[]){ start(new OrderManager()); }
static void start(CorbaComponent cc){ cc.print(); }
}
The output of this code snippet is:
URL://IOR
Can somebody explain the flow of this program? Somehow I got lost with how startUp(String s) and getIORFromURL(String s) in the OrderManager class get called during execution.
Thanks

Here is a mock exam question on Thread:
public class TestClass extends Thread
{
static Object lock1 = new Object();
static Object lock2 = new Object();
static volatile int i1, i2, j1, j2, k1, k2;
public void run()
{
while (true)
{
workWithLocks();
workWithoutLocks();
}
}
void workWithLocks()
{
synchronized(lock1) { i1++ ; i2++; }
synchronized(lock2) { k1++ ; k2++ ; }
j1++; j2++;
}
void workWithoutLocks()
{
if (i1 != i2) System.out.println("i");
if (j1 != j2) System.out.println("j");
if (k1 != k2) System.out.println("k");
}
public static void main(String args[])
{
new TestClass().start();
new TestClass().start();
}
}
After the execution of the synchronized lock1 method, without the presence of wait() and notifyAll(),will the method release the object automatically ?
Thanks