I recently was working on a J2EE application on Tomcat that contained a sub-folder named “admin”. During most of the development process the application was not being run from the “/” root context. When the application was moved to the root context the “admin” sub-folder conflicted with the “/admin” context that Tomcat comes with by default. No problem, I just directed my browser to the “/manager” context and clicked the “remove” link for the “/admin” context. Conflict resolved. But the next day I turned my development machine back on and the conflict was back, Tomcat had re-deployed the “/admin” context! After a bit of research I found out that the entry for the “/admin” context is generated through a file called “admin.xml” in Tomcat’s webapps directory. To permanently remove the “/admin” context you can just delete the “admin.xml” file. If you want to keep the administration tool you can alter the path attribute of the context element in the admin.xml file. I was able to remove my conflict by changing the path attribute from “/admin” to “/tomcat_admin”.
Archive for September, 2004
Tomcat Administrator Conflict
Friday, September 17th, 2004Validating all fields on a form
Thursday, September 16th, 2004The following Javascript can be used to verify that a value has been entered in all fields on a form.
function validate(form) {
var regex = /\w+/;
for(var i = 0; i < form.length; i++) {
var curr_el = form.elements[i];
if(!regex.test(curr_el.value)) {
alert("Please fill out all fields.");
curr_el.focus();
return false;
}
}
return true;
}
Checking for empty form fields
Tuesday, September 14th, 2004When using JavaScript to validate form input one might be tempted to use:
if(document.form.field.value == '') {
alert("Hey, enter a value");
return false;
}
- or -
if(document.form.field.value.length == 0) {
alert("Hey you, yes you the guy who pressed enter or clicked 'Submit', enter a value");
return false;
}
The problem with these two methods is that they don’t prevent the user from just tapping the spacebar within the field to be validated.
A slightly more sophisticated approach is the following regex, which checks for the presence of alphanumeric characters.
if(document.form.field.value.match(/\w/) == null) {
alert("Please enter something in the field before you hit the submit button again");
return false;
}
Up and running with WordPress
Monday, September 13th, 2004Well, I’m up and running with WordPress. Credit to my friend and co-worker Yuval for getting me to start this blog. I was going to start hacking away with my rusty Perl skills and put together my own blogging application, but a month has gone by and I’ve only made it as far as a putting together a preliminary database schema. During my lunch break today I decided to take a look at WordPress’ site and couldn’t resist trying it out after seeing the “5-minute” installation instructions. I followed the instructions and BANG, after five minutes I had nothing to show but blank pages. I found several posts in the WordPress forums pertaining to the problem, but I was running out of lunch hour. Tonight, when I got home from work, I prepared to settle in for some hardcore troubleshooting. But, before I got too far into the WordPress source-code I decided to re-download the zip-file and step through the instructions one more time. Second time was the charm!