JSP Tutorial #20 – JSP Forms Radio Buttons



JSP Tutorial #20 – JSP Forms Radio Buttons

JSP Tutorial #20 - JSP Forms Radio Buttons

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 HTML forms with radio buttons. I’ll cover the following topics. First off, I’ll start off with the radio button demo, then we’ll look at the actual HTML code for building radio buttons, and finally we’ll pull it all together with the full JSP page example. A lot of good things here. Let’s go ahead and get started.

All right, so here’s the radio button demo. We’ll have the student’s first name and last name but now we want to have the student choose their favorite programming language. Here we’ll give the first name and last name and then they can go through and select their language, Java, PHP, C#, or Ruby. Once they have their favorite language selected, then they can go ahead and hit submit. What we’ll do is we’ll actually generate a confirmation page with the language that they selected. Here I give the student’s favorite programming language and in this example the user chose PHP.

Let’s go ahead and look at the HTML here for radio buttons. You’ll set up your input type of radio and you give the name, favorite language, and the value “Java” and then an actual label for the user to see. You repeat this for each one of the languages here, for C#, PHP, and Ruby. The key here is that the input type equals “radio.” That will give you a radio button.

All right, so let’s go ahead and pull it together with an example. We’ll have a student radio form where our user will enter their information and they can choose their favorite programming language. They’ll hit submit and they’ll go across to a JSP page that will actually process it and display the student’s favorite programming language.

As you know I love to do lists here. The first thing we have to do is create our HTML form and then the second thing is create the JSP confirmation page. A lot of good things here. Let’s go ahead and start coding.

Let’s go ahead and move into Eclipse. Just like all the previous videos, we’ll continue to use the same project, JSP Demo. Also like the previous video, we’re going to make use of the student form as our starting point and we’re going to simply copy it and rename it. I’ll just right-click on student-form.html, I’ll select “copy,” and then I’ll right-click on it and select “paste.” When I paste it, I am going to give it a new name. The new name that I’ll call it is student-radio-form.html. Once I’m happy with that, I’ll go ahead and click the okay button.

Here’s our form, student-radio-form.html. Let’s go ahead and double-click this. Let’s expand the window here for a second. The first thing that we need to do on line seven is just update the response page. The response is going to be “student-radio-response.jsp.” We haven’t created that page yet but that’s where we’ll actually send the data when we submit the form.

A lot of this stuff is from before. What I’d like to do is go ahead and enter the HTML here for the radio buttons. I’ll start off here with the favorite programming language. Then I’ll set up the input type. The input type equals “radio” and the name equals “favorite language.” That’s the actual form field name. Then the value equals “Java.” This is for this given radio button. I’ll also just put the label out there to the right.

Then what I can do is just copy this X number of times for all of the other programming languages. I’ll just kind of speed the video up here real quick and just update it for C#, PHP, and Ruby. But now here’s the end result. I’ve basically I have four radio buttons here and they’re for each one of the programming languages. The key here again is the input type equals “radio.”

End of JSP Tutorial transcript.

Comments are closed.