Henry Leung

Greenhorn
+ Follow
since Oct 26, 2003
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 Henry Leung

Thanks both of you, then I will rewrite it in simpler style.

Especially Peter, I have never thought of the check-initialization-in-all-code-path thing. I will keep that in mind.
13 years ago
When editing an old application, I see code like this:



As you can see, this is a Comparator subclass. It is used to sort Collection that could have thousands of MyClass objects.

In order to compare 2 MyClass objects, it makes use of their IDs, retrieved by the getId() method.

I just don't understand why it uses StringBuffer, then call StringBuffer.toString() to get another String instance with same content as the original one......

Does String has any synchronization or concurrency issue, so that using a separate instance gives better performance??

(The original programmer is unknown so I can't ask him why.......)
13 years ago
Thanks Jeanne!

I compared our WSAD project to a new Eclipse 3.2 project, found that the Eclipse project has a few more lines in its .project file. Those lines are:



I added them to our WSAD project's .project file, then the "Project Facets" section appeared.
[ October 31, 2006: Message edited by: Henry Leung ]
When I right-click on a newly created "dynamic web project" and choose "Properties", there is a "Project Facet" section, in which I can add/remove project facets.

But when I try to do the same thing to our existing web project (created by WSAD 5.1), there is no "Project Facet" section in the "Properties" list. How can I make it appear, so that I can add/remove project facets?

Originally posted by Yuriy Fuksenko:
1. if you have access to your server configuration, you should be able to define an alias for your "getreport.do" and call it whatever you want.

2. Depending on your server abilities and traffic you expect, you may have an option of creating a temp file on you server, naming it whatever you want, write report into it and provide it to user.



Thanks for your suggestions.

I thought of option1 before. It is rather tricky and would add difficulty to the webapp's maintainability in the future. So I took it as a last resort.

For option2, I don't prefer it because it induces another problem about how to control user's accessibility to a physical file on disk. By streaming through a servlet, the servlet can use the user-setting of the webapp.
When streaming an excel file to client, how to let client opens it directly in IE without losing the filename I specified?




I am writing a struts webapp. When user clicks a particular button, the html form will be submitted to http://mydomain.com/mywebapp/getreport.do. An excel file will then be streamed to user. User can choose to open it directly in IE, or save it.

This is how I set the http header in the Action class:


It works fine. User will be prompted to open or save the file. The filename myexcelfile.xls is displayed in the prompted dialogue box. If user chooses to save, myexcelfile.xls will be the default filename.

However, if user chooses to open it, the filename myexcelfile.xls will be lost. The excel file will be directly opened in IE. If user clicks File --> Save As, the default filename provided will be getreport.do.

I don't want this to happen, because such a filename (getreport.do) might confuse the user. Does any know a solution?
14 years ago
When streaming an excel file to client, how to let client opens it directly in IE without losing the filename I specified?




I am writing a struts webapp. When user clicks a particular button, the html form will be submitted to http://mydomain.com/mywebapp/getreport.do. An excel file will then be streamed to user. User can choose to open it directly in IE, or save it.

This is how I set the http header in the Action class:


It works fine. User will be prompted to open or save the file. The filename myexcelfile.xls is displayed in the prompted dialogue box. If user chooses to save, myexcelfile.xls will be the default filename.

However, if user chooses to open it, the filename myexcelfile.xls will be lost. The excel file will be directly opened in IE. If user clicks File --> Save As, the default filename provided will be getreport.do.

I don't want this to happen, because such a filename (getreport.do) might confuse the user. Does any know a solution?
Our server has 4GB RAM, and it runs nothing else except the JBoss Appserver and Apache HTTP server. So I think we can definitely afford a heap size as large as 1-2GB. However, I heard that there are some concerns when the heap size is larger than 1GB. Some say these problems are platform/OS-dependent. I wonder if there is any information about this issue?

My environment:
Windows 2003 Entreprise Edition, JBoss 2.4.8, J2SE1.3.1
[ September 09, 2005: Message edited by: Henry Leung ]
14 years ago
yes, or more generally,
How to delete large amount of rows in a table, where the table is OR-mapped with an EntityBean?


I always thought that JDBC is not applicable in my case, and calling EJBObject.remove() for each row is the only way to do it (though I know it's slow). I would be glad to know that if I am wrong......

Originally posted by Mishti Sengupta:
hi,
using DAO is best choice in such circumstances..

entity bean becomes less performing if you deal with huge chunk of data..
u can also use...session bean + jdbc...




oh, I thought that with EntityBean OR-mapped to a table, I can't use JDBC to modify or delete rows from the table, or else the data persistency will fail. So this is not true??



_____________________________________
For Global Circle of Friends
http://sakshi.bravehost.com[/qb]
[ July 20, 2005: Message edited by: Henry Leung ]
thx both of you~~

But in fact what I need to do is to delete those rows. So the value list handler (I guess the main idea is to cache)won't help here. And, if I use JDBC to execute a delete SQL statement, with EntityBean deployed, there will be data persistency problem, right?
I have thousands of rows in a table and I need to retrieve them all out to process. But I think it's not a good idea to fetch them all by a single call of findAll(). I would like to retrieve them, say, 50 by 50 repeatedly. So, I wonder if there is any tricks to declare a finder method, so that it retrieves at most 50 records at a time?

For reference, I am using JBoss 2.4.8 and Sybase ASE 12.5. But you can just ignore my server environment and tell me any approach you know. THX~~
I browsed the grammar list on the official homepage, and the page http://www.cobase.cs.ucla.edu/pub/javacc/, to which many websites link to. But there are really not many to download.....

I would like to find a grammar file for parsing advanced sybase sql. Does anyone know where to get one?

Originally posted by Peter Rooke:
Have you tried the JBoss Web Console (http://localhost:8080/web-console/). Otherwise you may have to look at JMX.



sorry, a typo, I am actually using JBoss 2.4.8.

It seems that my JBoss does not have a web-console. I don't see the relevant war in the deploy folder.

I am not familiar with JMX, just heard of it before. I did find a JMX web agent on port 8082. But it only provides configurations for the DataSourceLoader, such as max-pool-size, min-pool-size, timeout, etc.
15 years ago
I have a web app running on Jboss 2.4.3. I suspect that the connection pool size is a bottleneck of the app's performance. So I wonder if JBoss has any feature for me to monitor the usage of the connection pool? Say, to dynamically display how many connections are fetched, how many are in the pool, how many threads are waiting for a connection, etc.

If not, is there any analyzing tool to do that?
15 years ago