cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Scott <>
Subject NullPointerException with query parameters
Date Thu, 30 Nov 2000 14:53:02 GMT
Hi all-

I didn't see this one in the FAQ or in my personal mail archive. Sorry if it's a

I quite often set the value of XML tags from query parameters, or perform
actions based on a query param's value. I'm sure this is common practice:

  String action = request.getParameter("action");

  if (action.equals("option1"))
      //do action

  else if (action.equals("option2"))
      //do something else


However, Cocoon (v 1.8, BTW) doesn't do very well when that query parameter
isn't set. I invariably get a NullPointerException from the populateDocument
method. Have I unknowingly violated some design rules? Should I use another
method for communicating control parameters?

I know in general it's not good practice to use parameters as control switches -
you're better off separating those two actions into two different
methods/functions/whatever. In this case I'm dealing with a confirmation before
an action - "Is this really what you want to do?" or "Please fill in these
details so I can perform the action." I thought it would be better from a
readability/maintainability standpoint to have one XSP perform those functions.
HTTP query parameters seemed to be the best way to communicate the state. I
could use session variables but then I'd have to clean up after myself. 


View raw message