Jsp dynamic gui

I am asking myself if there is some way to create a dynamic gui in jsp. So that I can have something like a dropdown for the country and based on what I have selected in that window, the dropdown for cities without reloading the jsp page. Or, in a dialog with multiple input lines, to add an additional line using a button, again without reloading the entire page. In the first case, the information about the cities will be in the database, and the second information provided will be stored at the end in the database, so I can't use the java script (and really don't want to).

0


a source to share


2 answers


At a minimum, you will need to use JavaScript to implement what you want. Most of them will do it as Tim describes in his first paragraph.

Set up two .JSPs: The first contains your main form in the country dropdown menu. Some JavaScript on the first .JSP fires an AJAX request to the second. JSP. The second .JSP takes a country id parameter and uses a servlet to query your DB for a list of cities and then displays that data. After the request returns, JavaScript in your first .JSP inserts the list of cities into a new dropdown menu.



It may sound daunting, but there are several JavaScript libraries that can help you with this task. Have a look at jQuery or Dojo .

0


a source


To refresh the page without publishing the entire page, the browser will use ajax. Using a database does not eliminate ajax. Ajax calls the server code that pulls your data from the database.



Whatever you need, without writing your own javascript, have a look at GWT (Google Web Toolkit). You are right ajax applications in Java that generate javascript for you.

0


a source







All Articles