Chris Gow wrote:
>
> I am working on a servlet that generates an HTML table where each table row
> contains information about a row in the database along with a checkbox.  The
> user selects the checkboxes next to the rows he is interested in performing
> additional processing on and then presses the submit button.  This posts the
> information to the next servlet, which presents additional screens.  I want
> to send several columns of data for each selected row, but the checkbox POST
> only allows for <name>=<value>.  What is the best way to pass multiple
> pieces of information between servlets in this manner?  Should I make the
> value a delimited string and have the next servlet tokenize it?  Or is it
> better to send one column of data and then have the next servlet re-query
> the database for the other columns?  Other better methods?  Tnx.

Either approach will work, and as with many design decisions, the answer depends
on the requirements of your project.

Certainly a delimited string will work, and I've done that approach.

Another approach I've used is to encode each piece of information in a hidden
input tag, where the value from the check box gives the name of the hidden input
field:

<input type="checkbox" name="id" value="1">
<input type="hidden" name="1" value="name1=value1">
<input type="hidden" name="1" value="name2=value2">

In both of the previous solutions, a person could modify the form to change the
data held by the form; then when the form is submitted, the next servlet could
get erroneous data. If that is a problem, then you would want to requery the
database. If queries are quick or there are few queries, you could go this way
even if it didn't matter that the data be kept secure.

Another alternative is to hold the query result in a structure accessible to
different servlets. Then the data is accessible without having to requery the
database, and you don't have to worry about clients being able to view or modify
data that you've hidden in the form. Here though, you need to ensure that you
have a way to identify where a request is coming from, which will probably
involve cookies or URL rewriting, and possible sessions and session management.

Kevin Mukhar

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to