JSP Tutorial #19 – JSP Forms Drop Down List



JSP Tutorial #19 – JSP Forms Drop Down List

JSP Tutorial #19 - JSP Forms Drop Down List

FULL COURSE: JSP, Servlets and JDBC (80+ videos)
http://www.luv2code.com/jsp (SPECIAL DISCOUNT)

—-

This JSP tutorial series will help you quickly get up to speed with JSP.

Download Tutorial Source Code: http://www.luv2code.com/downloads/youtube-jsp/jsp-tutorial-source-code-lite.zip

—-

View more videos on the playlist: JSP Tutorial: https://goo.gl/fFVMrj

Closed-Captioning and English subtitles available for this JSP Tutorial.

—-

Follow luv2code for more JSP tutorial:

Website: http://www.luv2code.com
YouTube: http://goo.gl/EV6Kwv
Twitter: http://goo.gl/ALMzLG
Facebook: http://goo.gl/8pDRdA

If you liked my JSP tutorial, then join my mailing list: Get exclusive access to new Java tutorials.

– http://www.luv2code.com/joinlist

Questions or problems about this JSP tutorial? Post them in the comments section below.

Want to suggest a video for my JSP tutorial? Leave a comment below. I’m always looking for new video ideas.

Let me know what video you’d like for me to create.

Premium JSP Course

Need More Details on JSP?
– See my Premium JSP and Servlets course (80+ videos)
– http://www.luv2code.com/jsp

JSP Tutorial Transcript

Hello. In this video, I’m going to show you how to build drop-down lists with HTML forms. We’ll cover the following topics. First off, we’ll see drop-down lists in action, and then I’ll show you the HTML code to build a drop-down list. Finally, we’ll pull it all together with a full JSP page example.

Let’s go ahead and get started. First off, here’s a drop-down list in action. We have a student, and they can select their country. We can give them all the different options of the countries here. This is an example of a drop-down list. I’ll show you the HTML code on how to build this type of drop-down list.

Let’s look at the HTML code for building a drop-down list. Basically, you make use of a “select tag.” Here we have select and we say name=”country.” Then, you drop in all the different options that you’ll have here for the drop-down list. Here we have option: Brazil, France, Germany, India, and so on. This will actually help us build the drop-down list for our application.

Note here, where we have the select name = “country”; country, that’s the name of the form fill you use in your JSP page to read the form data. I’ll show you that later in the demo.

Let’s pull it altogether. We’re going to have an HTML form that’s going to request the student’s name, first/last, and also their country. They’re going to submit their form data, and then we’re going to have a JSP page that’ll actually process this and will display the student’s name and also display the user’s selected country.

I always like to have a “to do” list, so the first thing we’re going to do is we’re going to create an HTML form. Then, the second thing we’re going to do is build the JSP confirmation page. Let’s move into Eclipse and try this out. We’re in Eclipse. What I like to do is to continue to use the existing project, the JSP demo.

What we’re going to do is we’re actually going to have a form. The form is going to be very similar to the previous one, so I simply want to copy our previous form and use it as a starting point. Select student-form.html; just do a right-click and choose “copy.” Then, right-click and choose “paste.” We simply want to paste a copy of it, so just do a paste.

At this point, Eclipse will prompt you for a new name for the form. The name we’re going to use here is student-dropdown-form.html. That’s the new name of our form. Once you’re happy with the name, go ahead and click “okay.” Now we should have this new form here, student-dropdown-form.html. Let’s go ahead and open this form up and take a look at it.

I’ll expand the window here for a second. The first thing we want to do is, on line seven, we want to change the actual JSP page it’s going to point to. We want it to point to student-dropdown-response.jsp. Again, student-dropdown-response.jsp. That’s the new page that we’re going to create in this video for actually processing the form data from the drop-down list.

Now, everything else here is the same. Let’s move down to line 16 and let’s add in … First off, let’s just do some white space here. Let’s add in the actual tag for that drop-down list using a select tag. I’ll say select name=”country”, and here I’ll go through and add the different options for the countries. I’ll start off with the first country here: Brazil, France, Germany, and just more of the same. I’ll just repeat this for all the other countries here. I’ll speed the video up just to list out all the other countries here. These are all the countries, and this is our drop-down list. This is great. This is kind of what we wanted to do for building the HTML drop-down list. Good job so far.

All right, now let’s go ahead and work on our JSP page.

[Snip] for complete transcript of JSP tutorial, select “More … Transcript”

Comments are closed.