Howard Zhao

Greenhorn
+ Follow
since May 06, 2002
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Howard Zhao

Thank you for your prompt reply. I am really appreciated.

The user can:
1 close the browser if he is using browser to send http query to the servlet.
2 perform a �Cancel� operation in a MFC based c++ client side program. The mentioned program constructs http query and sends it to the servlet.
3 close the mentioned program.

Howard
17 years ago
I am coding servlet part in my project. Now I am facing a problem on how to detect the http client that sends http query to my servlet is cancelled / killed by users.

I have a working scenario like this: a user sends http query to my servlet, my servlet parses query data and according to the contents of the http query, my servlet issues SQL calls via JDBC. When SQL queries finish, the servlet reformats the SQL results and send them back to http client. For some reason, either the SQL takes really long time or the DB server is slow, or whatever, during the execution period of SQL queries, my servlet just waits there and sends nothing back to http client. From the front user's standpoint (the front user issues http queries), he thinks that his http query is "dead", and he performs a kill or cancel operation to stop the http query.

Now my servlet needs to detect this kind of action, while it is still waiting for SQL queries to end, in order to cancel the SQL queries and to save DB resources.

How to do this?

Howard

17 years ago
Hi
Thank all of you very much for the replies.
I have decided to change all the float-type variables to double-type.

Thanks again.

Howard
18 years ago
Hi

Thank you very much for your prompt response!

I very agree with you on that the inaccuracy is introduced by the floating-point number binary representation.

Besides the Java test, we also did a c++ test on Windows.

double d = (float) 3.14;
printf(�%0.20lf�, d);

The result is 3.14000000000000010000.

Why Java is not as accurate as C++? Is it because of different Java compiler implementation? Or because of different JVM implementation?

Thanks again

Howard
18 years ago
Hi

Maybe this is a very old topic and has been discussed thousands of times before, but now it gives me a big headache.

In my current project, I need to receive data from a legacy program. What I expected is a double value, i.e. 3.14, and what is given to me is a float value, i.e. 3.14.
When the float value casts to a double value, to my surprise, the resulted value changed and some no-zero decimals are generated in the cast result!

In order to investigate this issue, I did a quick test and the result is very interesting.

Here is my sample code

float testFloat = (float) 3.14;
double testDouble = 3.14;
double testDouble2 = (float)3.14;
System.out.println("testFloat:" +testFloat);
System.out.println("testDouble:" +testDouble);
System.out.println("testDouble2:" +testDouble2);

Here is the result
testFloat:3.14
testDouble:3.14
testDouble2:3.140000104904175

Clearly after casting, float 3.14 changed to 3.140000104904175

Why float 3.14 does not stay as double 3.140000000000000 and how to solve it?

BTW, I an using Oracle JDeveloper 10g, results are the same whether it is running in hotpot JVM or oracle OJVM

Thanks

Howard
18 years ago
Hi
I have posted this question to WebSphere online support (trial) and hope they can answer my question.
Howard
21 years ago
Hi
I have a similar problem on WAS5.1.
I deployed a servlet on WAS5.1 and this servlet serves requests sent from client. When small amount of data are sent back from servlet to client, every works fine, but if the amount of data exceeds a limit, servlet fails to send data to client. This problem does not occur on WAS4.0.
Does anyone have an idear?
Howard
21 years ago
Hi
Does anybody know how to determine whether a value has been truncated in a JList?
Thanx.
Howard
21 years ago
I am not sure whether this is what you are looking for:
KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner()
Howard
21 years ago
Hi
Suppose curFrame is your current working JFrame and myComp is the component whcih has focus.
Right before your worker starts, do
curFrame.getGlassPane().setVisible(true); //block mouse input
curFrame.getGlassPane().requestFocus(); //block keyboard input
After the worker finishes, do
curFrame.getGlassPane().setVisible(false);
myComp.requestFocus(); //set focus back to get keyboard input.
Howard
21 years ago
Hi
In my application, I have two lists (Jlist masterList, JList slaveList) and 9 JComboBoxes.
When an item in masterList is selected, the data in slaveList is updated as well, then data in JComboBoxes is updated consequently.
What I do is
if an item in masterList is selected, I will set slaveList.setSelectedIndex(0), in slaveList's valueChanged(ListSelectionEvent e) method I update data in JComboBoxes.
The problem I have now is that since it takes quite a while to update slaveList when an item in masterList is selected (the new data in slaveList has to be fetched from a servlet in an independent thread),, when arrow-down or arrow-up is kept pressed, after several updates, the masterList stops responding, (Of course, after JComboBoxes are updated, masterList
is the focus owner), but page-up and page-down work well.
Both lists are set setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
Any idears?
Thanx.
howard
21 years ago
Hi
In my JDBC implementation, I need to alter session's trace value sometimes.
Befrore I alter the current session trace value, I need to know whether the current trace has been enabled or not. We know that trace can been set in ini.ora, if trace has been set in ini.ora, I do not need to enable trace at my JDBC connection. How can I retrieve the default SQL_TRACE value?
Thanx
Howard
21 years ago
Hi
In my applet � http  servelt �JDBC  DB model, when the applet sends a request to servelt, the servlet picks up a JDBC connection from connection pool and assigns the connection dedicated to serve the applet. Since the applet sends many request (one after another, not simotaneously) to servlet during applet life time, the servlet needs to know, in order to serve the specfic applet, it needs to find the dedicated JDBC connection to offer service to the applet.
Because when JDBC connection finishes serving a request sent by applet, the connection can not be put into the connection pool, instead, it is put into a servlet hashtable table so that at next request, which is sent by same applet, the servlet can pick up the connection from the hashtable in order tokeep the dedicated service to the applet.
My question is since weblogic has a console to monitor the behaviour of connection pool and connections,
I do not know whether my above try has some impact on the monitoring or on some other weblogic features. Can someone tell me?
Another question is since I use a stateful session bean as a timer to time out a connection when the onnection is out of the pool (in other words, for each JDBC connection, when it is out of the pool, a stateful session bean is created to be a timer to time out the connection), and the bean dose nothing but timing. When times up, it gets itself removed and on the same time, the JDBC connection the bean is timing on will be closed and put back to the JDBC connection pool.
My question is can I use a stateful session bean like this? Whether there will be some impacts on the console bean monitoring , JDBC monitoring or other things?
Thanks in advance.
21 years ago
Hi
1 You can pack the .ini and classes into a .jar or .war file, each time you modified the .ini, you need to pack them again and redeploy the pack.
or
2 Directly moidfy the .ini in your pack and redeploy the pack.
or
(I am not sure whether this will work out, but servlet reload .ini in this way)
3 put you .ini file in your bean (or bean container ) working directoy, redeploy the bean classes.
I think the .ini file only can be read during component initial time, so each time you modify your .ini file, youneed to redeploy the component
Howard
21 years ago