C
ccjjharmon
Good afternoon all.
I am at a loss of trying to figure out how to cleanly map what a user
selects on a JSP-driven webpage to an Java object.
Let me get right into the details:
A servlet interfaces with the databases and gets two Collection objects
that I set as attributes with request scope. The servlet then
dispatches its related JSP to "show" the user a pulldown menu for each
of the Collections. I iterate thru the collections' objects via JSTL,
but my problem is when the user submits the form on the JSP (which
submits to a "controller" servlet), I am only sending just one piece of
the selected object from the collection.
Now I know I *can*:
change the collection to some sort of list that has key to lookup
objects (e.g. ArrayList with its index per object)
persist the collection into session scope,
use the object key as the pulldown menu's option values
and within the servlet/JSP (whatever's next according to the controller
servlet), get the object that is returned from the key found by
request.getParameter()
But is this the best method? I kind of feel dirty doing it, but don't
really know why.
Are there are any other ways??
Anyone done this and care to comment on advantages/disadvantages?
I am at a loss of trying to figure out how to cleanly map what a user
selects on a JSP-driven webpage to an Java object.
Let me get right into the details:
A servlet interfaces with the databases and gets two Collection objects
that I set as attributes with request scope. The servlet then
dispatches its related JSP to "show" the user a pulldown menu for each
of the Collections. I iterate thru the collections' objects via JSTL,
but my problem is when the user submits the form on the JSP (which
submits to a "controller" servlet), I am only sending just one piece of
the selected object from the collection.
Now I know I *can*:
change the collection to some sort of list that has key to lookup
objects (e.g. ArrayList with its index per object)
persist the collection into session scope,
use the object key as the pulldown menu's option values
and within the servlet/JSP (whatever's next according to the controller
servlet), get the object that is returned from the key found by
request.getParameter()
But is this the best method? I kind of feel dirty doing it, but don't
really know why.
Are there are any other ways??
Anyone done this and care to comment on advantages/disadvantages?