To pass a lot of parameters (too mach)

F

Ferro

I have a JSP page that write out an HTML form.
On this form I have a lot of Input tag, so that users can insert
a lot of parameters.
After a submit, I need to call a servlet, and to pass all that
parameters to him.

It is very ugly write:
servlet?par1=val1&par2=val2& ...... &parN=valN

So I ask: is there a way to pass a lot of parameters from an
object to another (from JSP to a servlet, and maybe from a
class to another class) with elegance and dinamically (when N
is not knew)?

I thought to XML, but it doesn't like me.
Have you another idea?

Thanks a lot.
Ferro
 
M

Millian Brave

What about passing a single String where the parameters are separated by a
separator character (i.e a space)? This approach would only be suitable if
the parameters are simple data types (i.e Strings, integers etc.), though.
 
M

Michael Borgwardt

Ferro said:
I have a JSP page that write out an HTML form.
On this form I have a lot of Input tag, so that users can insert
a lot of parameters.
After a submit, I need to call a servlet, and to pass all that
parameters to him.

It is very ugly write:
servlet?par1=val1&par2=val2& ...... &parN=valN

So I ask: is there a way to pass a lot of parameters from an
object to another (from JSP to a servlet, and maybe from a
class to another class) with elegance and dinamically (when N
is not knew)?

For that kind of request, you probably want to use method="POST" for the
form. The parameters will then not appear in the URL. Actually, you should
use that for all requests that submit data (as opposed to requesting to
display data).
 
F

Ferro

For that kind of request, you probably want to use method="POST" for the
form. The parameters will then not appear in the URL. Actually, you should
use that for all requests that submit data (as opposed to requesting to
display data).

OK, this can be a solution,
but if I'd need of a global way, to use between classes too???

Some way, usually working with table's DB, you can't know
how many parameters you will have to pass from a class
(or JSP page) to another class (or servlet).

By example, a SQL SELECT istruction on a table, can need to
some WHERE clauses.
But the number of WHERE clauses depend from the table.
So a method as GET_RECORD could need to a variable
parameters number.

XML will be fantastic, but a lot hard to parse.

So I ask something other :)

Thank you very much.
Ferro.
 
D

Daniel Schneller

Hi!
but if I'd need of a global way, to use between classes too???

Can't you put the information you need into a session? This would limit
the URL parameter to the session id (if at all, when cookies are disabled).

Daniel
 
J

John C. Bollinger

Ferro said:
I have a JSP page that write out an HTML form.
On this form I have a lot of Input tag, so that users can insert
a lot of parameters.
After a submit, I need to call a servlet, and to pass all that
parameters to him.

It is very ugly write:
servlet?par1=val1&par2=val2& ...... &parN=valN

So I ask: is there a way to pass a lot of parameters from an
object to another (from JSP to a servlet, and maybe from a
class to another class) with elegance and dinamically (when N
is not knew)?

I thought to XML, but it doesn't like me.
Have you another idea?

(1) You can direct the form submission to the servlet in the first
place. This is cleanest if suitable, as only one resource in your
webapp needs to handle the request.

(2) You can use a <jsp:forward> or <jsp:include> to make the servlet
operate on the same request and response objects that the JSP processing
the submission gets. This avoids either redirecting the client or
generating an internal HTTP request.

(3) You can extract the parameter map or the individual parameter values
from the request and store them in the session. This is compatible with
redirecting the client or generating an internal request back to the
same webapp. (And also with a forward or include, but it has less value
in those scenarios.)

(4) You can write the data into the request body of an internal HTTP
request. You have full control of the data format this way, but it is
not compatible with a client redirect.

(5) You can use the POST method instead of the GET method to make the
client's user agent put the parameters in the request body instead of in
the query string. This doesn't help you for a client redirect, however.


John Bollinger
(e-mail address removed)
 
F

Ferro

how about passing an array of object references

Yes!
Everytime, the more simple (or simplest ???) is the best! :)

Thank you.
Ferro.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top