JSP Tutorial #21 – JSP Forms Checkbox Part 1



JSP Tutorial #21 – JSP Forms Checkbox Part 1

JSP Tutorial #21 - JSP Forms Checkbox Part 1

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

Hey, in this video I’m going to show you how to use HTML forms and check boxes. We’ll cover the following topics, we’ll first start off with a check box demo, and then I’ll show you the actual HTML code for creating check boxes, and then we’ll pull it all together with a full JSP page example. All right, so a lot of good things in store here, let’s go ahead and get started.

All right, so let’s start off with the check box demo here. The user can enter their first name, and last name, and now the new thing that’s here is that they can actually choose multiple programming languages. That’s thanks to check boxes. Previously they could only use radio buttons, and choose only one language, but now they can choose multiple languages, which is good, because of more flexibility because we may personally like more than one language. Once you’re happy with that you can go and hit submit, and now our confirmation page is a little bit different. Now since they can choose multiple languages, then we’ll simply display a list of all of the languages that they actually selected. We’ll do some slightly different coding here on our confirmation pages, but that’s the big picture anyway.

All right, so let’s go ahead and look at the code here for HTML check boxes. It’s very similar to radio buttons, the only difference is the actual input type, so instead of type radio, we say type equals checkbox. Other than that everything else stays the same. Input type of checkbox, name, favorite language, value of java with the label off to the far right. You can just repeat that process for each one of the languages, C#, PHP, and Ruby. Again, very similar. The only thing new is the type equals checkbox.

All right, so now that the user can check multiple boxes, we need to change our coding up a little bit in our JSP page. Now in our JSP we won’t be able to use the lowest shortcut syntax of the dollar sign, curly brace, param, because now we’re going to get a lot of different values back. What we can do instead is make use of the request object. I’ll say, “Request get parameter values,” and then I’ll give the parameter name, “Favorite language.” This get parameter value will like to return an array of strings, right? That makes sense, right? Because they can choose multiple programming languages now, so it’s going to return an array of strings, then it will write some JSP Scriplet code, and we’ll actually loop through that array, and print out an HTML list of the data. Anyway, things will be a little different when we get into the coding there for the JSP and we’ll make use of this technique for that.

All right, so let’s kind of pull it all together. For this demo, or project actually, we’re going to have a student check box form, they can enter their information, choose multiple programming languages, hit submit, then they’ll go over to the JSP, we’ll give them their confirmation information, and then we’ll loop through all languages selected, and then display them as an HTML list.

All right, so you know how I love to do lists. The first thing we have to do is create the HTML form, and then the second thing we’ll do is create the JSP confirmation page. What I’ll do is I’ll actually break this up, and show in a separate video as far as all the eclipse coding. I’ll see you in the next video.

End of JSP tutorial transcript.

Comments are closed.