Win a copy of Java EE 8 High Performance this week in the Java/Jakarta EE forum!

Stephen Huey

Ranch Hand
+ Follow
since Jul 15, 2003
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Stephen Huey

I don't see them in my
Windows machine's Eclipse which makes me wonder if they come bundled with Java 6 and not 5.
Hello everybody, I'm not sure what's up. Just moved an Eclipse project from a Windows machine running Java 6 to a Mac OS X Leopard machine with Java 5, and I'm seeing this

"The import javax.xml.bind cannot be resolved."

Is this simply an issue with Java 5/6 since my Mac doesn't have Java 6? All the same JARs are are in my lib directory and the build path looks the same, so I can't figure out why I can't see the JAXB stuff. I'm also using the Google App Engine plugin for Eclipse, but I don't think that's related.

Thanks so much...
Thanks for the tip! I'm actually planning to do this on Google App Engine, and it looks like it wasn't working for someone on GAE in December due to a dependency on javax.swing:

I'll try Velocity for now.
8 years ago

That example above shows how to use Velocity to take in a template XML file and merge your data into it to output a populated XML file. If I want to output an XML file with dynamic data by using some kind of template tags in an XML file, is Velocity the best choice out there?

Basically, if I have a template file with stuff like

in it, do you recommend Velocity for populating it?

8 years ago
I thought I'd post my complete solution for posterity's sake. Pardon me for the code formatting being off.

My goal was to create Microsoft Office files on Google App Engine for Java, and since some of the the tried-and-true libraries for writing the old binary Word and Excel formats (such as Apache POI) aren't currently supported on GAE, I decided to try to create the relatively new .docx and .xlsx formats.

You can read the whole story here:

The most relevant bit of the code is below. Note that I'm using the GaeVFS library which is on top of the Commons VFS library. I had to do that since the usual File class isn't supported on GAE.

8 years ago
Wow, all I had to do in that ZipIt class was remove the initial forward slash from the ZipEntry name:

String[] files = new String[] {"D:/stylessub/styles.xml", "D:/document.xml"};
String[] entryName = new String[] {"stylessub/styles.xml", "document.xml"};

Awesome. Thanks to a Python programmer:

8 years ago
I can't find a solution for this anywhere! I'm creating a .docx file (a Microsoft Office XML file, which is simply a zip file with certain directories and files in it). My zip files created with Java's ZipOutputStream class are being opened just find on Mac OS X, and I tried changing the file separator to a couple different things, but Windows XP is still complaining that my generated zip file (which I'm leaving with a .zip extension for now) is invalid or corrupted and won't open it. However, Winzip will open it on Windows. That won't work for my users, though, because I need Microsoft Office 2007 to be able to automatically open these files.

Before, I was using the Apache Commons VFS, but now I've reverted to simple examples just to try to get a basic case working. Windows opens my generated zip file just fine as long as there are no subdirectories, but I must have subdirectories, and I can't find a way to get Windows Compressed Folders to play nice whenever I try to include files in subdirectories.

Here are 2 bits of sample code. The first one generates a zip file that Win XP Compressed Folders won't even open, but the second one opens even though it doesn't have the "subdirectory" zip entry in it. Does anyone know why?

Here's the one that generates a zip file that Win XP Compressed Folders can actually open:

The resulting zip file is 38 KB, but if I comment out the files String array and only insert the one file, the file size is 21 KB, so it seems like the file is being inserted, but Windows is not recognizing the one coming from the subdirectory. Any ideas?
8 years ago
I'm trying to add a new forward path and JSP to a Struts action servlet that already uses XDoclet annotations. Someone else wrote those, and I have no idea why I'm getting the error below:

It seems so generic. All I've done is add a ViewTransaction forward, but all I get is a blank page and the above error when I try to use it (and the new JSP I created is in the same directory as some old ones already in use). See below for a snippet of my code with a working forward (ViewAccount) and the new forward:

Why might this be happening? It seems really simple.
9 years ago
I moved to a new team, and I found out they don't use the Eclipse debugger (just debug statements). No one on my old team knows how the debugger got set up, and I tried copying a few arcane lines from several startup files with no success. Then I tried following the simpler instructions here:

It seems like it should just work. However, when I go to the debug dialog in Eclipse and click New under Remote Java Application, I can put in all the info, but when I go to select the Project, nothing appears (there's nothing to select!). I'm already in the project in Eclipse and I just go to the Debug perspective--there are files open and everything. Does something need to be turned on in an Eclipse project to make it debuggable?
I put in the text incorrectly for the second (bad) environement (actually, the browser rendered it differently from the way I typed it in). What we saw in the XML in the 2nd environment was:

"Stephen" followed by the ampersand symbol followed by "amp;" followed by "#39;s"

This gets incorrectly rendered as "Stephen" followed by the ampersand symbol followed by "#39;s"

So, I know that #39 is the correct numeric code, but I'm wondering if what's happening is some sort of halfway conversion. On the following page, the correct numeric code for an apostrophe has the ampersand symbol in front:

So if we now for some reason have

[ampersand symbol] plus "amp;" plus "#39;"

then I'm guessing the parser might translate

[ampersand symbol] plus "amp;"

into the ampersand symbol and on that cycle of converting it didn't know what to do with "#39;" since it didn't see an ampersand symbol in front of it. What I don't know is why that would've happened in the first place!

[ May 01, 2008: Message edited by: Stephen Huey ]

[ May 02, 2008: Message edited by: Stephen Huey ]
[ May 02, 2008: Message edited by: Stephen Huey ]
XStream is used to generate XML in our application, but I don't think this problem is specific to XStream. I'm wondering if there's something I can do in Java to make sure that this problem doesn't happen.

We are sending an XML file to another internal application, and I'm having trouble with an apostrophe in one of the XML nodes. It's a simple object and there is no special converter registered for it, and its comments field is just a String. In two UNIX testing environments, we are seeing different behavior, and I don't even know where to begin to look for the cause. At first, I assumed their parser was mishandling something, but upon investigation, we found out that this is what they're seeing in the XML file they receive from us:

XML: <comments>These are Stephen's comments.</comments>

Actually, it's not exactly what you see above--it's actually Stephen followed by an ampersand followed by apos; and then the final s (the end of "Stephen's"). Anyway, this renders correctly as: These are Stephen's comments.

In another environment (that should be the same as far as character encodings are concerned), here's what they see coming from us:

XML: <comments>These are Stephen&#39;s comments.</comments>

"Stephen's" gets incorrectly rendered as Stephen followed by an ampersand followed by #39; followed by the final s.

I don't know how this could be happening if the code is the same. Has anyone seen something like this before? Is there a way I can put in a bit of safety code to make sure this doesn't happen in any environment?


[ May 01, 2008: Message edited by: Stephen Huey ]

[ May 01, 2008: Message edited by: Stephen Huey ]
[ May 01, 2008: Message edited by: Stephen Huey ]
I'm mainly familiar with Struts, but I've been browsing numerous other web frameworks including Tapestry, Webwork, Wicket, etc. Do you know which one might be highly suitable for creating a small web application and would also make it really easy for a UI developer to concentrate on the HTML/CSS while a Java developer worked on custom tags and servlets and back-end code?
They don't have to install anything. We have full control of the machines, and users only have limited interaction with them. The UI designer has decent skills making pretty visuals with webpages, and I know more Java web development than I do Swing. We're also leaning towards Linux, and it seems like remote management of Tomcat might be fairly hassle free. Plus, it is possible to lock down a web browser fairly well to keep users messing with the machine in ways they shouldn't. I don't have anything against a standalone app, but this web-based approach should work well, right? We'd also have the option to display remote webpages in the same browser window (and that will most likely be necessary). We could also consider putting a browser window in a standalone app, but I'm not sure if we would benefit from that approach.
[ November 16, 2007: Message edited by: Stephen Huey ]
10 years ago
I think I have a solution to a problem, and I just want to see if anyone has thoughts or concerns that I may need to address. Basically, users will be interacting with my machines in a limited manner, and I want the simple interface to be web browser-based, but I need some functionality that is generally only available in a standalone app (e.g. filesystem access and I don't want to use an applet). In other words, I don't want the user to have to use a standard file-save dialog (I want the app to more automatically handle some of those things).

So anyway, I think I can get everything I want by installing Tomcat on each machine, because the server code will have filesystem access, etc. The webpage the user sees can be updated from the local Tomcat server via AJAX to show file transfer progress, etc, and instead of using a standard file save dialog, I could show whatever kind of abstracted file transfer interface I want through AJAX.

I'm going to try to code a rough implementation soon, but I'd like to hear from you if you see any mistaken assumptions I might have (or foresee any other difficulties I might encounter with this strategy). Thanks so much...
10 years ago
I want to have several locked-down workstations where a simple web app can run and users can't access much else. The machines will download large files from a remote server and need to then be able to detect and transfer the file to a user's plugged-in (USB, etc) or wireless (Bluetooth) device. I would like for the user to be seeing a simple web application, but since I need it to transfer files to a user's device I'm wondering if I should have a local web application running (e.g. on Tomcat) that handles all interaction with the user (except for when contact must be made with the remote web server) and can also somehow kick off some local code that will handle the transfer to the external device. Does this sound reasonable? Could I achieve this in some way other than using an applet? I mean, could the local web server kick off some code to look for the user's device and transfer the file?
10 years ago