Billy Hause

Greenhorn
+ Follow
since Jan 16, 2002
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 Billy Hause

Ernest Friedman-Hill wrote:

Billy Hause wrote:
n my tests between Java and C++ using a standard sorting algorithm to sort a random list. I've found Java to be 5 to 10 times slower than C++.



That was a very flawed benchmark, then. People have done these sorts of tests for years, and if you compare a number of different C++ compilers and a number of different Java runtimes, you find that the difference isn't anywhere near that large: when the tests are done properly, the best C++ and the best Java results are always within a factor of 2 of each other. In general, the very best C++ compilers do win -- as they do here, for example -- but the common compilers like g++ and (cough) Visual C++ are not the best compilers. A good JVM often outperforms C++ code compiled with these less-than-ideal compilers.



With all due respect, that sounds like wishful thinking to me. Java is a great language but it's not very fast compared to a compiled language like C, C++ or Objective C.
Here is a link to benchmarks performed and published by Google. http://www.readwriteweb.com/hack/2011/06/cpp-go-java-scala-performance-benchmark.php
It's just common sense that any language that runs in a VM (JIT or not) will not be any where near as fast as the native equivalent.
11 years ago
iOS

nik gen wrote:Hi,

There are many differences between java and Objective-C. Few of them are as below.

1. Java has Garbage Collection, Memory is handled by developer in Objective-C.
2. Java has static typing, where as Objective-C has dynamic.
3. Objective-C has rich API to develop GUI comparatively Java.

Apart from this, there are some pros and cons for each language.

Pros of Java:
1. Platform Independent.
2. Availability of many third party libraries.
3. No header files or function prototypes.
4. Direct access of member variables.

Pros of Objective-C:
1. Categories.
2. Use standard C code natively.

Cons of Java:
1. Performance cost of the brifge. JavaBridge, XcodeObjCJavaBridge.
2. Performance cost of the Virtual Machine.
3. lots and lots use of memory.

Cons of Objective-C:
1. Need to handle memory management explicitly.
2. Not as many as resource available.
3. Objective C is somewhat slower than Java. But the fact is Cocoa-Java is slower than Cocoa-Objective-C. also pure java is faster.

Thanks,
Niketa.



"Objective C is somewhat slower than Java."
Is that a typo?
The best Java could hope for is to be slightly slower than the native equivalent.

In my tests between Java and C++ using a standard sorting algorithm to sort a random list. I've found Java to be 5 to 10 times slower than C++. I can only guess the same would be true for Java vs. Objective C.


11 years ago
iOS
Solution Found!

The request canot be parsed more than once but the resulting List object can have new iterators created so the solution is to pass the List to the handler function instead of the request.

Thanks,

Billy
17 years ago
I should have posted this code to begin with but better late than never.

Here is my code. If I make a call to upload.parseRequest(req); after the code shown below, then the List that is returned is empty. I would like a way to reset the request so that I can pass it on to a handler function and parse the request again in the handler.

Thanks again for any help,

Billy

// Check that we have a file upload request
if (ServletFileUpload.isMultipartContent(req))
{
// Create a factory for disk-based file items
FileItemFactory factory = new DiskFileItemFactory();

// Create a new file upload handler
ServletFileUpload upload = new ServletFileUpload(factory);

// Parse the request
List /* FileItem */ fileItems = upload.parseRequest(req);

// Process the uploaded items
Iterator iter = fileItems.iterator();
while (iter.hasNext())
{
FileItem item = (FileItem) iter.next();

if (item.isFormField())
{
// Process a regular form field
sMsg += "FILE FORM FIELD - Name, Value: " + item.getFieldName() + ", " + item.getString() + "\n";
}
else
{
sMsg += "FILE UPLOAD - File Name: " + item.getName() + "\n";
sMsg += "FILE UPLOAD - Content Type: " + item.getContentType() + "\n";
sMsg += "FILE UPLOAD - IsInMemory: " + item.isInMemory() + "\n";
sMsg += "FILE UPLOAD - Size In Bytes: " + item.getSize() + "\n";
}
}
17 years ago
Thanks for the reply Bear,

ServletFileUpload is a class in the org.apache.commons.fileupload.servlet package.

I believe most file uploads are done using this class so I thought someone in this forum may have used it before and know the answer to my question.

I spent time going throught the documentation for this class before posting my question but was not able to find the answer.

I'm still needing a solution to the problem so if anyone who reads this knows the answer I would appriciate hearing it. Otherwise I will find some sort of a work-around.

Thanks

Billy
17 years ago
I'm using ServletFileUpload and parseRequest(req) to accept file uploads to the server.

It seems to be the case that once you call parseRequest to get a List of file items, you can not call it again later.

I would like to parse the request once to figure out what is being uploaded and then pass the request off to a handler to process that particular kind of upload.

The problem is that the handler can't parse the request because it's already been parsed earlier to determin what handler to send the request to.

Is there some way to preserve the request so that the handler can parse it or can requests only be parsed once by ServletFileUpload.parseRequest()?

Thanks for any help. It seems lame to me that parseRequest() would modify the request in such a way that it can't be parsed again later.

Thanks

Billy
17 years ago
I'm trying to get my site working on a Windows XP machine. It is currently working on a Windows 2000 machine.
I'm running tomcat v4.04
When I enter the URL for the site, Windows pops up a dialog box asking me to enter a User name and password. Why is it doing this and how do I stop it? No username or password that I can think of get me past the dialog. After three tries a page comes up that says "Unauthorized"
Thanks,
Billy Hause
20 years ago
Does Java have any built-in FTP capability?
My java program needs to FTP a file to an FTP site. How do I do that?
Thanks,
Billy
21 years ago
Does anyone have a simple example showing how to use MysqlConnectionPoolDataSource to get a pooled connection to a MySQL database?
Thanks,
-Billy
Thanks Much!
21 years ago
JSP
I put this at the top of my JSP
<jsp:useBean id="userInfo" scope="session" type="hause.user_management.User"/>
Now I get the following error:
javax.servlet.ServletException: bean userInfo not found within scope
What causes this error? (This is the first time I've tried to use the useBean tag in my jsps.)
Thanks,
Billy Hause
21 years ago
JSP
I do have the XSLT Programmers Reference by Michael Kay. I also have the XML Bible. In the XML Bible at the bottom of page 437-438 (under topic XSL Style Sheet Document) it states:
"You cannot use XSL to transform to or from non-XML formats like PDF, TeX, Microsoft Word, PostScript, MIDI or others."
It then goes on to say:
"XSL transformation language works for XML-to-XML conversions, not for anything else."
If XSLT can transform into anything, then why isn't there an XSLT to transform XSL FO into various popular formats such as PDF or Microsoft word? Currently you need a custom program to do it.
-Billy "sometimes doen't know what he's talking about" Hause
I read that XSLT can not transform XML into a non-XML format. Is this true?
Is there an XSLT that can transform legal XML like this
<NAME>Joe</NAME>
into illegal XML like that shown below missing the end tag?
<NAME>Joe
Thanks,
Billy
Thanks, but that solution doesn't list each state only once. I need to eliminate duplicates.
Thanks anyway.
-Bill