Dan Temple

Ranch Hand
+ Follow
since Jul 10, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Dan Temple

I do know servlets and JSP (or at the very least am studying them now). I am reading the EXCELLENT text "Core Servlets and Java Server Pages" by Marty Hall.
Just wondering what other topics I should be reading
Dan
23 years ago
JSP
Hi everyone,
I am going to be starting to work on my first big web project in a few months, and was wondering what I should be reading in the meantime. I don't know anything about web security or UML. Should I start learning about one of these? Which do you think is more important? Can anyone recommend some good books?
Thanks in advance,
Dan
23 years ago
JSP
Okay, Thanks for the reply folks!
Dan
24 years ago
Hi everyone,
I am very new to the wonderful world of setting up webservers; in fact I know only the basics about client-server architecture, and I think if I am hardpressed I might be able to SPELL "Servur" (er ... never mind). So to boldly go forth and grapple with my server-ignorance I am going to try and develop a web application using servlets. I am reading an excellent book on the matter "Core Servlets and JavaServer Pages" and so far it looks like a snap. However I think that 90% of my time and brain haemorrhages will come from just setting up the server, rather than writing actual code.
I think I will use the Apache Tomcat, but I have a few questions:
1) Apache is the webserver and Tomcat runs the Servlets and Jsp in that environment. Is this correct?
2) I have heard that setting up Tomcat is ... er ... *cough* ... CHALLENGING, so I was thinking of buying the book "Apache Jakarta-Tomcat" by James Goodwill. Has anyone bought this book, and if so can they recommend it?
3) If my assumption about (1) is correct, I will need to install the Apache Webserver first. Is this as challenging as setting up Tomcat, and if so will I need another book just to do that?
4) What are the system requirements for running Apache and Tomcat in a windows environment?
Any insights or advice would be very much appreciated
Dan
24 years ago
Okay ... this has always confused me.
Other than costing me many precious hours of my life, is there actually a REASON why Java is case sensitive? Or to be more general why on earth would we want any languages or O/S to BE case sensitive?
Dan
24 years ago
Hi everyone,
I am going to be writing a program that spawns a single thread to do the basic processing of the program, while the event dispatch thread listens to user events. As the loop that the basic processing is performed in is not trivial, is the only way to exit gracefully from this thread to poll some variable that is affected by user events? This would mean that in order to keep the GUI responsive I would have to keep repolling the variable after any time consuming processes within the loop. This seems kind of crude doesn't it?
i.e.
While(Variable says keep going)
{
Poll Variable
Stuff
...
Stuff
...
Poll Variable
...
Stuff
...
Poll Variable
etc
}

Is there a more elegant solution?
Dan
Hello everyone,
I have made a GUI program that is called from native code. Basically the GUI runs as a screensaver. When the GUI is single-threaded (i.e. the GUI Thread only) the program runs flawlessly. However when I make it multi-threaded after a while the screensaver stops running and when I hit alt-ctrl-del I see that I have one or more Java tasks running in the background. So obviously something is wrong with my threading. I am having a heck of a time tracking the progress of the Java code since when the code is called from the native code, there is NO command prompt window and hence I can�t do the standard: System.out.println(�Executing X_Routine�), trick for debugging. I tried using a text file log, but if the program crashes before it closes the log, then I don�t get any debugging info. So I guess my two main questions are the following -
1) What is the best way to track down errors in such a situation.
2) I really, REALLY miss having output automatically directed to the command prompt window. Is there anyway that I can force this?
Thanks in advance
Dan
24 years ago
Hello everyone,
I don't know anything about C or C++, but of course the project I am working on requires a java class to be called from an executable. The GOOD news is I found the C code that will do this in the book I am using (Core Java volume 2). The BAD news is I can't get the &**&^(*ing code to compile! Actually I can get it to compile, I just can't get it to link properly. The name of the code is InvocationTest.c.
I am using the free Borland compiler (V5.51) under windows 98. The book says that in order to compile the code under the Windows C++ compiler, I need to type:
cl -Ic:\jdk1.3\include -Ic:\jdk1.3\include\win32 InvocationTest.c c:\jdk1.3\lib\jvm.lib
In borland I assumed that the syntax would be
bcc32 -Ic:\jdk1.3\include -Ic:\jdk1.3\include\win32 -Lc:\jdk1.3\lib\jvm.lib InvocationTest.c
However when I do this I get :Error Unresolved external 'JNI_CreateJavaVM' referenced from C:\MyC++Source\InvocationTest.obj
I guess my questions are
1) What the heck does this MEAN?
2) How do I get it to play nice and compile?
Any hints or answers would be really, REALLY appreciated
Dan
PS - I AM using Java 1.3
PPS - I double checked and the jvm.lib DOES exist under c:\jdk1.3\lib
24 years ago
Sorry for the length of the post. I guess I should also say that the Java Tasks appear only when it is launched from the native code, not when I run the classes from the command prompt. I guess that means its definitely a problem with the native code.
Dan
24 years ago
Hello all you Java Wizards!
I found a very interesting site, http://kevinkelley.mystarband.net/java/sava.html, which allows you to write screen savers in java on Windows platforms. It uses compiled native code to invoke the java virtual machine, consults the control.ini to determine which class to load and run using that virtual machine. I was overjoyed since this is exactly what I was looking for, for a project I am working on. I tried it out, choose the native code as a screensaver within the control panel -> display, and it indeed worked! However I noticed that though it worked about 75% of the time, it would cease working after a while. Hitting-alt-ctrl-delete I saw that there were several instances of Java tasks running. I consulted the java code for the classes and saw that it was using the now deprecated stop() method. So I wrote my own classes to be called by the compiled native code. And this worked too! Except again it only worked 75% of the time and would cease to work after a bit. Hitting-alt-ctrl-delete again there were several instances of Java tasks running. Consequently I think one of two things are occurring:
1) Despite the fact that there are only two threads running in my java code (a main thread and a worker thread) somehow there is a deadlock, hence the java tasks that continue to run and somehow inhibit further java program starts by the native method. I�m not sure how this would be possible, but it is consistent with the �usually works, but sometimes doesn�t� property of my java code. However there is no Hanging of the GUI or anything that is run.
2) The problem lies not in the java code but with the compiled native code and somehow in the invocation API the DestroyJava function is failing to execute. This would explain why there is no Hanging of the GUI, but only Java tasks that fail to terminate. However I don�t know why the Java tasks would only fail to terminate sometimes.
I really, REALLY hope it is the first possibility (but I think it is number 2). I don�t know any C++ or C, and I really don�t want to spend 6 months learning it just to write some native code that will run a JVM as if it were a screen saver.
I tried to contact Mr Kevin Kelley, but the email on the site is no longer working. Does anyone have any ideas as to what I should do here? I have included my java code in the hopes that the flaw lies within it. I have not included the native code, since I only have the compiled native code ... unfortunately.
My Java classes are quite simple. A small window with a panel is created. There is a JTextField in the Panel, and a custom event source (Counter) starts looping in a for loop, and each loop number is passed to the JtextField so that the Panel begins counting up. A MouseMove over the Panel informs the Counting thread to cease, dispose methods are called and the thread exits. Here are the classes
----------------------------------------------
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;

public class DanScreen
{
public static void main(String args[])
{

Frame frame=new Frame("Dan's Mad Project");
frame.setSize(200,200);
SaverWindow dan=new SaverWindow(frame);
dan.show();
frame.show();
}
}
---------------------------------------------------
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
public class SaverWindow extends Window implements Runnable
{
private Frame frame;
private Counter c;
private int count=0;
private CountPanel panel;

public SaverWindow(Frame aframe)
{

super(aframe);
frame=aframe;
setLocation(0,0);
setSize(300,300);

panel=new CountPanel();
c=new Counter();
CountListener tListen=new CountListener();
c.addTimerListener(tListen);
panel.add(c);
ScreenMouseListener sml=new ScreenMouseListener();

panel.addMouseMotionListener(sml);
add(panel);

c.startNow();

}

public void panelCleanUp()
{
dispose();
frame.dispose();
System.exit(1);
}

public void run()
{
panel.setCount(""+count);
}
class CountListener implements TimerListener
{
public void countIncrement(TimerEvent te)
{
count=te.getCount();
EventQueue.invokeLater(SaverWindow.this);
}
}
class ScreenMouseListener extends MouseMotionAdapter
{
public void mouseMoved(MouseEvent me)
{
System.out.println("MouseMotion event");
c.stopCount();
panelCleanUp();
}
}
}
---------------------------------------------------
import java.awt.*;
import java.awt.event.*;

import java.util.*;
import javax.swing.*;
import java.io.*;
public class CountPanel extends JPanel
{
JTextField countField;


public CountPanel()
{
countField=new JTextField(20);
add(countField);

}
public void setCount(String s)
{
countField.setText(s);
}
}
--------------------------------------------------------
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
public class Counter extends JComponent implements Runnable
{
private int count=0;
private EventListenerList listenerList;
private boolean stopRequested=false;
private Thread t;
public Counter()
{
listenerList=new EventListenerList();
count=0;
t=new Thread(this);
}
public void startNow()
{
t.start();
}
public int getCount()
{
return count;
}
public synchronized void run()
{
for(;;count++)
{
try
{
Thread.sleep(5);
}
catch (InterruptedException e)
{
}
EventQueue queue=Toolkit.getDefaultToolkit().getSystemEventQueue();
TimerEvent event=new TimerEvent(this);
queue.postEvent(event);
if(stopRequested)
break;
}
}
public void stopCount()
{
stopRequested=true;
}
public void addTimerListener(TimerListener listener)
{
listenerList.add(TimerListener.class, listener);
}
public void removeTimerListener(TimerListener listener)
{
listenerList.remove(TimerListener.class, listener);
}
public void processEvent(AWTEvent event)
{
if (event instanceof TimerEvent)
{
EventListener[] listeners=listenerList.getListeners(TimerListener.class);
for(int i=0;i<listeners.length;i++)>
{
((TimerListener)listeners[i]).countIncrement((TimerEvent)event);
}
}
else super.processEvent(event);
}

}

Well there it is. I would really welcome any suggestions that the good people on this site might have, I really have no idea how to proceed here.
Dan
24 years ago
Hi Everyone!
Ye Gods! Look at the number of posts in here!! (First time here)
I told my friend that I would be happy to do some Java Server work for him so I can get some marketable experience. The only problem is ... I DON�T KNOW ANYTHING ABOUT SERVLETS OR JSP!!! Its a pretty straightforward project though, he wants a program on the server that takes in info and stores it into a database, so I am assuming I�m going to need to know about servlets and JSP (and maybe a bit of JDBC). Can anyone recommend any good books on the subject? I am a SCJP so I am comfortable with the Java syntax, but know next to nothing about running Java on a Server. Ideally I would like something that starts with the basics and builds from there with LOTS of examples to illustrate what they are talking about. Maybe even something that builds an example Server project???
Also, my intuition tells me that the best way to design this is to have the program collect the info into an XML file, and then from the XML file put it into the DB. I�m not sure why my intuition tells me this ... something about being able to easily change the DB later. But I don�t understand how this could be, after all the server is still going to have to translate the XML into the DB, so where is the value in going to XML first? Of course it is possible that my intuition is totally off base here, its usually only super accurate when it comes to blind dates!
Thanks in advance,
Dan
24 years ago
Okay! I had some juice and thought about it. I got it, I got it. I thought EventListenerList was in the package javax.swing, but in reality I have to import javax.swing.event. Doh! Sorry for the short curcuit there ... it was one of those days, you know?
Dan
24 years ago
Okay, I must be blind, or my Java compiler is whacked. Why in the name of the heavens won't this stupid code COMPILE??? I have been doing all kinds of swing stuff in this directory, and now all of a sudden this happens:
import javax.swing.*;
public class Frustrated extends JComponent implements Runnable
{
// Copied DIRECTLY from java api docs!!!
EventListenerList listenerList = new EventListenerList();
}
The compiler keeps complaining:
C:\classes\Frustrated.java:20: cannot resolve symbol
symbol : class EventListenerList
location: package swing
javax.swing.EventListenerList listenerList = new javax.swing.EventListenerList();
WHAT DO YOU MEAN YOU CAN'T RESOLVE THE CLASS EVENTLISTENERLIST ??? ITS A STANDARD JAVA CLASS!!!
GRRRRRRRRRRRRRRR!
Well, I feel a little better now ... but I think I need a new keyboard. Anyway, I would be grateful to anyone that can point out my stupidity in this case ...
Dan
24 years ago
That does help quite a bit. I have a chapter in a book that shows how to make custom events so I'll work from that. One question though. In my original code I can understand why the countup would not occur at a constant rate (since it would depend on when the thread for painting was executed) but why would there be periods of a second or so when there was nothing in the text field? Is it because during those times the entire GUI is being cleared and then painted?
Actually on second thought, I lied, I don't understand why the countup is not at a constant rate. I'm not doing anything to the GUI so why is it painting it over and over again? (assuming that I am correct that this is the cause for the jerky count rate)
Also I just wanted to say that the Certification Study Guide you co-wrote was a damn fine piece of work. I doubt I would have scored as high on the SCJP exam if I didn't have that book.
Dan
24 years ago
Hi everyone,
I am experimenting with GUIs and am trying to do something relatively simple. I have a countdown program (hence the NASA reference) that displays numbers in a textfield. Well, technically it counts UP, but that is beside the point. Anyway, I have a separate thread to do the counting, and it seems to work, excpet that periodically the numbers in the textfield flash off for a second, but the counting still continues, and then the numbers reappear. I am suspecting that this has something to do with Java repainting the GUI. Anyway, here is the code, its pretty basic:
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import javax.swing.*;
public class Supercount
{
public static void main(String args[])
{
Frame frame=new Frame("Dan's Mad Project");
frame.setSize(200,200);
Window dan=new Window(frame);
dan.setLocation(0,0);
dan.setSize(300,300);
CountPanel panel=new CountPanel();
dan.add(panel);
dan.show();
frame.show();
Thread runner=new Thread(panel);
runner.start();
}
}
public class CountPanel extends JPanel implements Runnable
{
JTextField countField;
public CountPanel()
{
countField=new JTextField(20);
add(countField);
}
public void run()
{
int count;
for(count=0;count<10000;count++)
{
countField.setText(""+count);
repaint();// My attempt to fix the problem
}
}

}
Anyone have any ideas on how I can get a nice smooth counting display? I suppose slowing down the counting would work, but are there any other ways?
Thanks in advance,
Dan
24 years ago