cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sonny Sukumar" <>
Subject Best practices for validating request params?
Date Sat, 28 Jun 2003 21:19:35 GMT

Hi guys,

I was wondering what the best way is to validate request parameters.  I have 
a few questions:

1.) What is the best way to validate the *existence* of all expected request 
params (both for simple queries and for posting form data)?

By this, I mean I'd ideally like to notify the client if any request param 
wasn't sent.  I was thinking I could write a dedicated action to do this 
validation before another action extracts/formats the values.

2.) Do you think it is even a good practice to take the time/effort/cpu 
power to validate that all expected request params were sent and notify the 
client if they were not?

Otherwise, my action that extracts/formats the values would just end up 
throwing things like NullPointerExceptions, NumberFormatExceptions, etc. 
when it tries to extract/format the values.  This doesn't seem very elegant 
at all to me, even if I do wrap them in ProcessingExceptions before throwing 

One other reason I don't want to throw these seemingly odd and random 
exceptions is because they'll just give a stack trace that says my code 
failed on Line XXX.  On my team we have another development group that is 
working on buiding the actual XHTML webpages and making sure they work with 
the backend.  So these sorts of exceptions and stack traces won't help them 
at all to figure out what went wrong.  If I notify them they forgot a param, 
they can say "Oh , I forgot to pass the XYZ param--that's why it's failing" 
and fix their XHTML code in short order.

I'm interested to hear all of your thoughts!



STOP MORE SPAM with the new MSN 8 and get 2 months FREE*

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message