Min Huang

+ Follow
since Sep 21, 2004
Merit badge: grant badges
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 Min Huang

I thought so. I ended up writing a task that read in id's and image file paths from a properties file, then executed a sql update on all of them. Here's the class:

Target def looks like this:

Unfortunately, mysql's load_file only works on the host computer (ie the computer the mysql instance is running on), so this didnt work when I tried running ant load on another database:

[ April 18, 2007: Message edited by: Min Huang ]
[ April 18, 2007: Message edited by: Min Huang ]
15 years ago
I am trying to load a bunch of images as seed data into MySQL as part of the build process. Currently, I have an image.sql file that contains binary data, which the mysql client tools will happily import into MySQL:

Unfortunately, the ant sql task fails to parse this file correctly because of the binary data and fails. I've tried combinations of keepformat, encoding, and escapeprocessing, but I still can't execute that sql file via ant.

I have a shell script that loads the data, but I'd really like to be able to use ant and not require mysql client tools or cygwin/unix to be able to load data into the database.

Here are my options:
a) Find out a way to make the ant sql task work with binary data
b) Find out a way to load binary data using mysql's load_file with ant. The load_file function requires an absolute path, so I would need some way to only specify relative paths in the sql file and have ant do the rest. I dont think this is even possible.
c) The least attractive option is to have a <exec> task execute the mysql binary with the correct args. But I dont think there's a way to do unix file redirection; it wouldn't work on Windows.

Any suggestions?
15 years ago
If you attach a debugger to your webapp while its running, break somewhere, and make a code change (works in Eclipse and IDEA), that change will be reflected instantly and you won't have to reload the context.
15 years ago
If you put

at the top of your page, it will attempt to go forward a page in your history. If you go to another page, and then try to click back and go to this page, you will be bounced forward.

As an aside, if you do this, people will hate you. True story.

You probably want to use a servlet Filter to make the user go to the right page after authentication. Or use Acegi and let it do the hard work for you.
15 years ago
I figured it out. You have to put <% request.setCharacterEncoding("UTF-8"); %> at the top of the JSP. The character encoding has to be done before any params are read, or else it wont work.

Having a scriplet in your JSP is no good, so you can make a servlet filter to do just that. Make sure it's the first filter in the chain or it might not work. Order matters.

You can use CharacterEncodingFilter in Spring, or write your own:

You can replace the page directives with this in your web.xml:
15 years ago
Setting the charset to gb2312 doesn't work; I don't see the character I want. I've crafted a JSP that illustrates my problem:

Specifically, I have:
1) <%@page pageEncoding="UTF-8"%> set.
2) <%@page contentType="text/html;charset=UTF-8"%> set after the first directive.
3) <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/> in the head.
4) enctype="multipart/form-data" attribute in the form.
5) accept-charset="UTF-8" attribute in the form.

The results I see are:
For a GET: �ˆ‘ is the result.
For a POST with enctype="application/x-www-form-urlencoded": �ˆ‘ is the result.
For any other POST encoding: No entry in request parameter map.

Btw, yes I am Chinese.
15 years ago
Yes, I realize that. I was just wondering if there is some easy way to do it. I did stumble upon ct-eclipse, but there is are no files available for downloading. I was hoping if somebody knew of an alternative.
I have a weird problem I can't quite figure out. I am also not even sure if I'm posting in the correct forum, so please move my post if necessary.

Basically I am trying to get an HTML post to work with a chinese character.

I have a form that is multipart/form-data encoded:

The form has a single input in which I am trying to send the chinese character 我. For some reason, I am not getting the right character back when I break and inspect my command object in Eclipse.

I've tried a few things:

a) I don't explicitly set a page directive. When I submit, I get this back as a string: 我

This strikes me as incorrect because it should be a unicode character along the lines of '\uxxxx'

b) I set the content type via a page directive:

This gets me a little bit closer; when I break, I see three characters: ���

I understand that in the encoding, some characters can have variable length (1-4), so I'm not surprised if 我 requires such an encoding. However, I should expect one character instead of three.

Does anybody know how to resolve this issue?
15 years ago
Sorry, I didn't specify that this is JUnit3 specific. I strongly suspect that there is nothing I can do in this situation..
Is there a way to do this? I understand that having this need reveals a deeper problem in my unit tests themselves (ie they are not actually unit tests, but functional or they are just plain bad, bad I tell you!), but please humor me
Also, if you don't want to nefariously subvert the <c:url/> tag, you can use jakarta's string taglibs that has a <str:encodeUrl/> tag.

edit: messed up the url
[ March 29, 2007: Message edited by: Min Huang ]
15 years ago
If anybody was following this, (and Mr. Bibeault, you're not going to like this), you can do this:

1) Write your own CustomUrlTag, possibly extending UrlTag.

2) Copy the c.tld from standard.jar into /WEB-INF/tld and rename it to something like custom.tld.

3) Modify the url tag in c.tld and change the class name to your custom url tag.

4) Put the following in your web.xml:
15 years ago
Yea. I agree with your thoughts on a), overriding standard behavior is a whole other can of worms altogether, and I think I'll just go with b). Thanks for your input.
15 years ago
Why do would an EL function would be better? I've considered these options:

a) Replace <c:url/>
b) Write <myc:url/>
c) Write an EL function and do <c:url value="${myc:encode(url)}"/>
d) Encode in a servlet and set the encoded url in the model

I prefer option a) because I already have a lot of JSP's to modify, but c) is still on the table if there is a compelling reason to choose it.
15 years ago
URL encoding; eg transform a relative url like /search/��� into /search/%FF%D0%D1, for example.

Also, a form submission isn't an option either.
15 years ago