The Artima Developer Community
Sponsored Link

Java Answers Forum
Programming Using JSP and servlets

2 replies on 1 page. Most recent reply: Sep 22, 2017 11:29 PM by Priya Arrora

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Biji Simon

Posts: 1
Nickname: bijisimon
Registered: May, 2015

Programming Using JSP and servlets Posted: May 15, 2015 10:33 AM
Reply to this message Reply
Advertisement
I am doing program in java .I have designed a jsp page which has 3 drop downlist's...country,state and district.I want to display the values in drop down list state when a country is selected...(for eg:-if india is selected,drop down list state must have only the name of states in india).In Mysql i have created 3 table's...table country has a primary key and country name.table state have state id,state name and a foreign key from country id...What is the code in servlet and jsp to do this?Pls help me to do this pblm...


Sujata Patil

Posts: 2
Nickname: jyorat
Registered: Oct, 2015

Re: Programming Using JSP and servlets Posted: Oct 28, 2015 8:54 AM
Reply to this message Reply
There are different ways of doing this.

1. Either you send a list of all the three at once and register a onchange event and set the values of next drop down by fetching corresponding list from map or something, but this is crude way and considering the huge number of countries and states you have if not cost effective and performance oriented solution.

2. write a Ajax call for onchange event of the country and state dropdowns and send the seected value based on which respective list of next dropdown values is returned which you can populate in dropdown in the data method. best approach as far as i feel.

3. submit the form on selection with just one param and populate new page with the next set of values... again not a good approach

Priya Arrora

Posts: 5
Nickname: priya456
Registered: Aug, 2017

Re: Programming Using JSP and servlets Posted: Sep 22, 2017 11:29 PM
Reply to this message Reply
Similar to Common Gateway Interface (CGI) scripts, servlets support a request and response programming model. When a client sends a request to the server, the server sends the request to the servlet. The servlet then constructs a response that the server sends back to the client. Unlike CGI scripts, however, servlets run within the same process as the HTTP server.

Flat View: This topic has 2 replies on 1 page
Topic: Regarding Java EE Application or Java Web Application Previous Topic   Next Topic Topic: send a string from client to server

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use