Damo_Suzuki wrote:
> 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
|