Douggie Fox

Greenhorn
+ Follow
since Jun 14, 2001
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 Douggie Fox

Hi,

I've got a fresh install of Tiger on my Powerbook and I've downloaded Java 1.5.0 and also Tomcat 5.5.9.

The problem I'm having is when tomcat starts it ignores my settings for JAVA_HOME and defaults to JRE_HOME. I've pointed JAVA_HOME to both the symlink /Library/Java/Home and also directly at the 1.5.0 install /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home
but to no avail. Any ideas what's going wrong?

Thanks in advance

Paul
15 years ago
Hi,

I'm having some problems installing Tomcat under Linux. I think the main issue is to do with permissions but I'm struggling to find any consistent advice.

I have installed tomcat and if I run startup.sh as myself I get error messages relating to "catalina.out: permission denied". If I login as su, startup.sh starts tomcat properly. This leads me to a number of questions:

What's the advice regarding which "user" should run tomcat? I've read that the user "nobody" should be used? If that is the case, is there any advice on how to do this? Should the permissions on the tomcat install directory be changed? Any ideas how to do this?

TIA

Paul
16 years ago
Hi,
I'm struggling to find a discussion on how Servlets & EJBs might interact with each other. Can anyone point me to any relevant resource either here at javaranch or elsewhere on the internet? I'm particularly interested in some example code that I can play around with.
Best
DF
Hello Frank,
Thanks for the info. I think I was 2 steps away from concluding the same thing. I had read the warnings about it being "a bad thing"...just wanted to get past chapter 1 though
Best
DF
17 years ago
...found my own solution
... to do with the the Invoker Servlet
reference to http://www.coreservlets.com/Apache-Tomcat-Tutorial/#Enable-Invoker

Best
DF
17 years ago
Hi,
I've started to look at Servlets but I'm struggling getting started. Here's where I'm up to:
1. Installed Tomcat 5.0 to c:\tomcat
2. Written and compiled HelloWorld servlet
3. Started Tomcat & navigated to http://localhost:8080 and the default page comes up. The preinstalled demonstration servlets work ok.
However....

I'm following Jason Hunter's Java Servlet Programming and he says to copy the HelloWorld.class file to c:\tomcat\webapps\ROOT\WEB-INF\classes, which I've done, and then navigate to http://localhost:8080/servlet/HelloWorld. Tomcat responds with:
HTTP Status 404 - /servlet/HelloWorld...the requested resource is not available...

I'm unsure whether I've put the class file in the right place or that I'm missing something. Do I need to do something with web.xml in this basic example?
Best
DF
17 years ago
Hi All
In RHE P235 you are warned against using if statements in synchronized methods. This is illustrated with:
public synchronized void mixedUpMethod() {
if(i<16 | | f>4.3f | | message.equals("UH-OH") {
try {wait();} catch (InterruptedException e) {}
}
// proceed in a way that changes state
notify() ;
}
The discussion says that if i = 15 and a first thread waits. Later another competing thread may change the i to -23444, at which point our original thread could get notified & pick up where it left off (this is the bit I don't understand) even though the monitor is not in a state where it is ready for mixedUpMethod().
Can anyone explain this last bit?
Regards
Paul

Hi All,
I'm trying to substitute System.out.println("Something") with a command that'll print to a test file.
This is what I've been trying:
import java.io.*;
class PrintToAFile {
public static void main (String args[]) {
try {
FileOutputStream fout = new FileOutputStream("test.out");
PrintStream myOutput = new PrintStream(fout);
myOutput.println("Hello There!");
}
catch (IOException e) {
System.out.println("Error opening file: " + e);
System.exit(1);
}
}
}

And this works ok.
However, I'm also playing around with threads and I'm just getting in a mess. How do I safely output to a file in the following code ie how do I replace the System.out.println() commands?
class BasicThread extends Thread {
int sleepTime ;

public BasicThread() {

this.sleepTime = 0 ;

}

public BasicThread( int sleepTime ) {

this.sleepTime = sleepTime ;
System.out.println( getName() +" " + this.sleepTime + " sleep time " ) ;

}
public void run() {

try {
System.out.println( getName() + " going to sleep" ) ;
sleep( sleepTime ) ;
System.out.println( getName() + " waking up" ) ;
}

catch ( InterruptedException e ) {}

System.out.println( getName() + " finished" ) ;
}
}

class TryBasicThread {

public static void main( String args[] ) {

BasicThread thread1 = new BasicThread( (int)(Math.random() * 5000) ) ;
BasicThread thread2 = new BasicThread( (int)(Math.random() * 5000) ) ;
BasicThread thread3 = new BasicThread( (int)(Math.random() * 5000) ) ;
BasicThread thread4 = new BasicThread( (int)(Math.random() * 5000) ) ;
BasicThread thread5 = new BasicThread( (int)(Math.random() * 5000) ) ;

thread1.start() ;
thread2.start() ;
thread3.start() ;
thread4.start() ;
thread5.start() ;
}
}
Regards
Paul
19 years ago
Junilu,
Thank you for your replies over the last couple of days. I'm now moving on from Bit Patterns!
Thanks to everyoneelse who joined this thread.
Kind regards
Paul Robinshaw
Hi,
If you have a long, tricky piece of code that needs decifering in the exam, does anyone have any techniques for keeping track of variables?
Paul
I understood the bit about the modulo, the things I didn't understand was "low order 5 bits" and "low order 6 bits". I do not know what these terms mean. Can anyone illustrate?
Regards
Paul
OK I can accept negative numbers don't follow the division by 2 formula. How does the division of -1 by 2 become 0? And how does the arithmetic shift right of -1 become -1?
Sorry, I'm just not getting it:-(
Paul
In RHE on p50 the following statements are made:
...shifts of ints use only the low order 5 bits, and shifts of longs use only low order 6 bits, of the right operand.
Can anyone explain this? Any ideas to its significance?
Regards
Paul
A note on p48 in RHE states:
There is a feature of the arithmetic right shift that differs from simple division by two. If you divide -1 by 2, the result will be 0. However, the result of arithmentic shift right of -1 right is -1. You can think of this as the shift operation rounding down, while the division rounds toward 0.
Can anyone explain this. I simply do not understand it.
Thanks
Paul
Thanks Junilu. Fully understood. Great windows Calculator tip too!
Regards
Paul