File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes State of requested data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "State of requested data" Watch "State of requested data" New topic

State of requested data

jbig zala

Joined: Sep 20, 2004
Posts: 11
hi friends,
i have html page that register new user. user have to fill neccessary info like address, loginname, password, country , state, city , area etc.
For country, city, area fields those will stored as number into database of user.
when user change country from combo box appropriate combobox should be filled with states of that country. same for state, city , area.
i.e. when during sending request we have to store an id of country and fill state combobox of that country and return result with selected country.

please suggest me how to achieve this using servlet ???
Henrique Sousa
Ranch Hand

Joined: Apr 29, 2004
Posts: 92

You have basically two choices: Javascript and Servlet. Through Javascript you would send the states for all countries and store it as arrays. Then you would switch the contents of the state combo box according to the country. That would cause the page to load slower (depending on the amount of countries/states you will load), but JS does not require lots of request/response cycles.
Using servlets, you would submit the page when the value of the country combo changes, then load the states for the selected country and forward again to the JSP. This way you send less data, but you will have to repeat this request/response every time the combo box's value changes.
W3C's specifications are a good source to learn advanced Javascript (I like the "Java Language Binding" links), in case you need it.

Henrique Sousa<br />SCJP 1.4<br /> <br />All men die, not all men really live - Braveheart, 1995
I agree. Here's the link:
subject: State of requested data
It's not a secret anymore!