Building dynamic web forms with servlets

D

Damo_Suzuki

HI,
I have a form that generates a HTML form. In the form I have a select
list with a few options. When one of the options is selected I want to
the form to generate another select box beside the original one.

Say, I have a select box with a list of countries in it. Then , when
the user selects a country, another select box appears containing the
cities in the selected country. I want it to happen without reloading
the entire page.

Is this possible with servlets? Can someone point me in the right
direction

Thanks
 
L

Lew

Damo_Suzuki said:
HI,
I have a form that generates a HTML form. In the form I have a select
list with a few options. When one of the options is selected I want to
the form to generate another select box beside the original one.

Say, I have a select box with a list of countries in it. Then , when
the user selects a country, another select box appears containing the
cities in the selected country. I want it to happen without reloading
the entire page.

Is this possible with servlets? Can someone point me in the right
direction

Servlets run on the server. The only way to invoke them is via a round-trip to
the server. You can make this more convenient for the user with Javascript
(AJAX) to handle the request and response under the hood.

There are tricks for dividing a page into independently updated parts, but
they are not really needed unless you have a very thick page and a very slow
connection. If you can design your page to be rather lean, then just go ahead
and reload the entire page.

Sometimes you phrase a question to yourself in terms of a particular strategy,
"How can I avoid a page reload?", which limits your options and blinds you to
costs. (Segmenting a page is more complex than showing a "normal" HTML page.)
It is useful to step back and ask yourself the question in terms of a goal,
"How can I make a smooth user experience?" Note that the first question is
computer-centric, the second human-centric.

- Lew
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

Lew said:
Servlets run on the server. The only way to invoke them is via a
round-trip to the server. You can make this more convenient for the user
with Javascript (AJAX) to handle the request and response under the hood.

More than that.

This is a textbook AJAX example.

Almost the hello world of AJAX.

Arne
 
M

murari garg

HI,
I have a form that generates a HTML form. In the form I have a select
list with a few options. When one of the options is selected I want to
the form to generate another select box beside the original one.

Say, I have a select box with a list of countries in it. Then , when
the user selects a country, another select box appears containing the
cities in the selected country. I want it to happen without reloading
the entire page.

Is this possible with servlets? Can someone point me in the right
direction

Thanks

hi
i think if you do same programme in JSP and in jsp page you utilize
action listener and in listener will act after user will going to
select your first option.and by threading your programme will going to
other option to user.
 
L

Lew

murari said:
i think if you do same programme in JSP and in jsp page you utilize
action listener and in listener will act after user will going to
select your first option.and by threading your programme will going to
other option to user.

Web applications should do no explicit multithreading, beyond making the code
thread-safe.

- Lew
 

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

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top