I am having difficulties while dealing with two linked drop down lists which the drop down list 1 will fetch the values from the DB and based on the user\'s selection, it wi
I am not in a mood to post an extended answer since @anirvan already perfectly sums it up in two words which I cannot outbeat: you're making a fundamental mistake.
To the point: Java/JSP runs at the webserver, generates bunch of HTML/CSS/JS and sends it over network from websserver to webbrowser. The webbrowser (e.g. MSIE, Firefox, etc) retrieves and understands alone HTML/CSS/JS and starts to display/apply/run it. If Java/JSP has done its task right, you should not see any line of it when doing rightclick > View Source in webbrowser. The only way to let code in webbrowser (JavaScript) and code in webserver (Java/JSP) to communicate with each other is to let JavaScript send HTTP requests and Java/JSP respond on it.
Sending HTTP requests in JavaScript can be done in several ways:
document.getElementById('formId').submit()
.window.location = 'http://www.google.com';
.new XMLHttpRequest()
and so on.Here's a bunch of "must read" links to learn how the one and other fits in each other and how one and other should be used:
Hmm, this answer is after all a bit more extended than I meant it to be... Anyway, hope that it helps!
You're making a fundamental mistake of assuming that the Java code present in the scriptlets gets executed at the client end!
take a look at the lifecycle of a JSP. After that you'll be in a much better position to understand why your code doesn't work.
thereafter, you should try looking into some Cascading Dropdown examples using AJAX.
if all that doesn't help - post in again and it'll be much easier to guide you through.