Form input focus always seems a pain to me, I don’t like all of the generated inline javascript that struts or other frameworks add to accomplish this and it always seems to be one issue or another. So here’s a simple solution that applies focus to the last input element in the document that has a class of focus. Short and sweet, nothing fancy, requires the jQuery library of course.

The javascript, preferrably in an external javascript file

Continue reading

I basically needed the update button to be the default action on clicking enter in the form, but there were multiple submit buttons in my form and they weren’t in the order I needed due to UI design. This was a quick and dirty solution to select an html submit button and make it the default when a user clicks enter from certain or all input elements on the form. It could be tweaked to give specific behavior to specific types of input boxes, such as invoking a tab on enter in between required elements, but the general idea is using jQuery to click the default button when the user hits enter.

Continue reading

Ran into some issues on some of our Java sites today and needed a quick fix to protect the sites from malicious Cross Site Scripting (XSS) attempts. If you’re not aware of what XSS is and have websites that have sensitive user data, you may want to read up, you’re probably vulnerable, which means your users are vulnerable. I’m not claiming this is a perfect solution, but it was easy to implement and corrected the vulnerabilities with form and url injection. We basically have a Servlet Filter that’s going to intercept every request sent to the web application and then we use an HttpServletRequestWrapper to wrap and override the getParameter methods and clean any potential script injection.

Continue reading

DHTML dropdown menu’s have been greatly improved in terms of accessibility, standards compliance, and weight using the Suckerfish technique of building pure CSS-based menus and then attaching a small javascript that allows Internet Explorer 6 to mimic the CSS hover method. Once the die-hards hanging onto IE6 let go, we won’t have to worry much about this anymore, but for now it looks like it’s going to linger for a bit.

Continue reading

Java image resizer servlet

I’m working on a photo gallery application running on Java 6 using Tomcat 6, JQuery for the client side, and images and xml generated from Picasa. I needed several sizes of images for thumbnails and animations and I wasn’t about to create multiple image sizes with Fireworks (I’m a lazy developer). Doing what every lazy developer does, I search Google for an image resize solution that would run on the application server and give me the sizes that I needed and take the manual work out of the equation. I found several PHP examples and disjointed Java examples, but no complete solutions. So, unfortunately I had to do some work to put something together.

Continue reading

I’ve recently been working with an SEO firm to improve our “keyword density”, structure and several other things on our public website. In their long list of recommendations was the task of producing nice pretty urls with relevant keywords, dashes instead of underscores, and so on, easily said, not so easily executed or so I thought. Our architecture in a nutshell is Apache web servers, fronting WebSphere application servers, running a Struts-based web application. Now if you know Struts, 9 times out of 10 your url’s are ugly, because a bunch of programmers didn’t care at all when they developed your application about the impact the urls would have on natural search and the framework developers pretty much left you with a bunch of “do.do”. Very quickly the SEO firm was recommending 70+ rewrite rules on the Apache server to resolve to the urls in the application and then custom work for each individual url to rewrite it to the friendly url, so that when Googlebot crawls the site it would traverse these friendly urls. I cringed at the thought of this suggestion, not only is this not maintainable, but when I run a local server I can’t use the rewritten urls, as my development environment doesn’t have a full blown http server with rewrite capabilities. I knew there had to be a better solution, I just wasn’t sure what it was.

Continue reading

There always comes that time, when you’re debugging a Java application, when you get to that compiled code inside that open source jar that you added to make your life easier. Whether there’s an actual bug or you’re just trying to understand some behavior or weirdness you’re getting from calling this third party API, sometimes it just helps to see the source. If you’re using Eclipse you’re in luck, things just got easier, well they’ve been easy for awhile, but if you weren’t aware of jad they just got easier. If you download and unzip the most recent version of JAD, Java’s fast decompiler, and add the appropriate Jadclipse plug-in for your version of Eclipse, set a little configuration and your workspace will decompile compiled code automagically. No more ugly class outlines, just raw source code. This is by far one of the essential tools a Java developer should have in their tool kit, just like Firebug for a Web developer. Here are some step by step instructions to get you going, of course I’m assuming you’re already using eclipse and have an existing workspace.

Continue reading

Author's picture

GreatWebGuy

Code jockey, cloud native enthusiast, technologist, car nut

Developer

West Palm Beach, FL