#!/usr/bin/env python import string, cgi, os, whrandom, pickle, sys import cgitb; cgitb.enable() #sys.path.insert(0, '/home/mu.org/home/gus/fm/fmblog') #import fmbloglib,fmblog print 'Content-type: text/html\r\n' print ''' gus mueller
Here\'s something to get over the fact that some web browsers don\'t like to play nice when passing parameters through forms. The problem is, sometimes when you want to pass a form variable which happens to be an empty string, some browsers will pass it just fine (as "") and others will just exclude it completely. A little consistency would be nice.

Use this in your jsp\'s or servlets to hold your request parameters in.

You can use the code below, or you can use the constantly updated version in my aurora.servlet package- Params.java

import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class Params { private Hashtable params = new Hashtable(); /** * take all of the parameters from the request and filter out the * ones with blank values. */ public Params (HttpServletRequest request) { Enumeration enum = request.getParameterNames(); while (enum.hasMoreElements()) { String name = (String) enum.nextElement(); String values = request.getParameter(name); if (values != null) { if (!"".equals(values.trim())) setP (name, values); } } } /** * Set a parameter */ public void setP(String parameter, String value) { params.put(parameter, value); } /** * remove a parameter */ public void removeP(String parameter) { params.remove(parameter); } /** * get a parameter, returns null if it isn\'t there. */ public String getP(String parameter) { return (String)params.get(parameter); } /** * return a parameter, or return the default_value passed if it * is not present. */ public String getPtd(String parameter, String default_value) { String s = (String)params.get(parameter); return s == null ? default_value : s.trim(); } }

All things copyright © 2001, 2002 August Mueller

gmdc:
flying meat
contact
resume
photos
images
free font
cocoa bits
java bits
unix bits
osx bits
cvsdist
my words
mcommand
ja
links
my rss feed
book list
who\'s linken\'
login
wishlist
theories

people
andy
byron
jeff
jeremy
joe
kory
lynn
mary
murphy
ryan d

when bored
slashdot
maccentral
y! most viewed
cars
there gus
explodingdog
the onion
dotw
tonypierce
prior art
chimera

resources
Cafe au Lait
Cafe con Leche
design patterns
anitpatterns
java r.o.t.d
c.l.c
c.l.j
c.s.m.p.h
c.s.m.p.c



'''