philihp.com

Category: Programming

Chained Struts Actions Accessible Only by Forward

So I just stumbled into doing this little trick. It may go against some pattern, or best practice, but I’m sure there’s a use for it somewhere. In Struts 1.3 (and probably any Struts 1.x), it is sometimes useful to have a request chain across multiple Action classes, maybe to break them up into more [...]

New in Java 7: switch()ing on Strings

Finally, Java can switch on Strings! No more inefficient strings of if/else chains or Hash lookups or translation into Enums. Finally just clean readable and intuitive code. switch(suit) { case "club": case "diamond": trickValue = 20; break; case "heart": case "spade": trickValue = 30; break; case "no-trump": trickValue = 40; break; } It’s actually just [...]

How to Create an Empty SAS Dataset

If you were to do this in SAS to create an empty SAS dataset: data mytable; run; It would actually create a dataset with one row. The data step cycles through once, hits the end (run), outputs a row, then comes back and finds it has no more rows to process so it stops. To [...]

Please stop creating links with target=”_new”.

Just stop. This is wrong; instead, use this: target=”_blank” I don’t know who started these nasty rumors that “_new” would open up in a new browser. As far back as I can tell, no browser has ever recognized “_new”. The whole point of the target dates back to when browsers used frames to split up your [...]

Using Eclipse WTP with Maven’s eclipse:eclipse Goal

If you use Maven’s “eclipse:eclipse” goal to generate a project descriptor for eclipse, by default you’re just going to get a plain Java project. You’ll have to add in the Dynamic Web facet in order to tell Eclipse that you can deploy this project in a web container. The easy way around this is to [...]

Servlet Filters mapped to JSPs in Tomcat

Servlet filters were introduced in the Servlet 2.3 spec a long time ago. They’re basically classes that you can add to any Java webapp that intercept every request and can do anything you can imagine (e.g., compress output, translate, handle authentication, the only limit is yourself). They’re added into the web.xml file where every webapp starts, [...]

How to get the Last Day of a Month in SAS

SAS has a really neat function called intnx, which will increment a date to the next of an interval. For example, if you have a date (any date. maybe the current date?), you can get the date of the first day of the next month by doing this: data _null_; d = ’11JUN2011′d; format d [...]

This is how I feel about C

I don’t think C gets enough credit. Sure, C doesn’t love you. C isn’t about love–C is about thrills. C hangs around in the bad part of town. C knows all the gang signs. C has a motorcycle, and wears the leathers everywhere, and never wears a helmet, because that would mess up C’s punked-out [...]

Adding Tiles to a Struts 1.3 Project with a Custom Request Processor

In Struts, if you wanted to do funny shenanigans (e.g. override the Roles checking for authorization, or override the ActionForm population to parse a JSON object rather than standard parameters) with the Struts Controller, up until Struts 1.2, you had to extend the Request Processor and configure the Struts ActionServlet to use it instead. This [...]

This is how I feel about Perl

Good code in perl is fine, but there’s something about bad code in perl that’s worse than bad code in other languages, something very HP-Lovecraft- mad-servants-of-the-elder-gods-chattering-in-the-extradimensional- insect-language kind of bad that makes my head hurt when I have to read it. Jish Karoshi on comp.lang.ruby