JSP Tutorial #18 – JSP Forms – Write some JSP code



JSP Tutorial #18 – JSP Forms – Write some JSP code

JSP Tutorial #18 - JSP Forms - Write some JSP code

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

Let’s go ahead and move into Eclipse. What I’d like to do is continue to use the same project as before, jspdemo. What I want to do is move down to the web content directory and create a new file. We’re actually going to create a new file for the html form. I’ll just do a right click, I’ll say new file. The name of this file, I’ll call it student-form.html. Once we’re happy with the name we can go ahead and click the finish button. Let’s go ahead and expand the window here. I’ll set up my basic html tags, and then I’ll set up a header for the title of this form. We can just go ahead and set up some body tags here real quick. Then we can start building our form.

Here, I’ll say form action equal student response.jsp. That’s the jsp file we’re gonna send the data to. We haven’t created the file yet. We’ll create it next, but that’s the actual file that we’ll send the data to. Now I need to simply go through and create some form fields. I’ll set up the form field for first name. Set up the input type as text, and the name is equal to first name. Again, that’s the exact same name we’re going to use on our server side on our jsp when we read the form data. Just set up some line breaks here, and now I’ll do a similar thing here for last name. So, input type equals text. Name equals last name. I’ll just do a quick copy/paste here on the line breaks.

Then, finally to wrap it all up I’ll up my submit button, so I’ll say input type equals submit, and then value equals submit, so the value of submit, that’s the actual label that you’ll see on the submit button. Oh, and I notice I have a type on line 17. I spelled the input type submit. I misspelled that one, so let me fix that with an I. Okay. Good. Now we’re good to go. This is the html form. It has a first name, last name and the submit button. Now let’s go ahead and create the jsp page that will process this. Our student response jsp, so, new file, and I’ll call it student-response.jsp. That’s the same name that I’ll refer to in the html form. Student-response.jsp. Once you’re happy with this name, you can go and click the finish button. Okay, great.

Let’s go ahead and set up our basic tags again, and set up our student confirmation, and then take care of the body. All right. This is where we need to start reading some of the form data. First off I’ll say the student is confirmed, and then I want to display their first name and their last name. I’ll make use of that shortcut notation, the ${param.firstname}, so it’s the same name from the html form, and then param.lastname, so basically here we’ll have first name, space, last name for that student once they’re registered.

All right, let’s go ahead and run the program. I’ll move over to the student-form.html. I’ll do a right-click, and I’ll say Run As, and I’ll choose run on server. Okay great, so here’s our form. We can go head and enter some information here. For the first name I’ll say John, last name of Doe. Once I’m happy with that I’ll hit the submit button. Okay great. Here’s our confirmation page. The student is confirmed, John Doe. That’s the result of us reading the form data that the user entered on their html form. This all looks really good. Good job. We were successful in reading html form data with a jsp page.

End of JSP Tutorial transcript

Comments are closed.