Summary
Keywords
Full Transcript
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, we're actually going to look at the code demo for using cookies with JSP. So let's kind of pull it all together with a real example. So, we're going to have three pages that we're going to build in this video. The first thing we'll start off with is a cookies homepage. This is for our little training portal. If the user has a favorite language selected, then we'll show them a list of new books on that topic, news reports, and hot jobs, and so on. By default, if they don't have any cookies set, we'll just simply make use of Java as their default language. Now, at the bottom, they have a link where they can actually personalize this page and choose a different language. So this will take us over to our cookies form, where they can select their own programming language or their favorite programming language. Here, Java, C#, PHP, Ruby. They can select that favorite language. Say, for example, they choose Ruby. They hit Submit. Then, at the the bottom, we'll give them their response page or confirmation page saying, "Hey. Thanks! We've set your favorite language to Ruby." Now, when they return back to the home page, then new versions of the homepage will make use of that cookie that was set and then show that information accordingly. Let's look at a real quick demo here. Starting at the home page, by default, the language is Java, so we're assuming that no cookies were set and we just simply default to Java. Now, the user can go through and personalize this page. Here, there's a form. They can choose a drop-down list, choose their favorite programming language. In this example here, I'll choose Ruby. Then, I'll hit the Submit button. Again, a confirmation page. Hey, we set your favorite language to Ruby. Now, when I return back to the homepage, it should personalize it for the Ruby language for me. Here, selecting return to homepage, and then here it is. New Books for Ruby, Latest News reports for Ruby, Hot Jobs for Ruby. Basically, what this page is doing now is it's simply reading the cookie value and reading that favorite language, and then it's customizing this page based on that cookie. Now, remember, cookies last for a long time, so I can actually close my browser and then come back in, and it'll actually remember that cookie information for me. So cookies are persistent based on the actual age you set for the cookie, and it'll last for that given time period. So we see this works out for us in this example. Good job so far. All right, so let's talk about writing code, but I always like to start with a to-do list. The first thing we're going to have to do is create an HTML form to personalize the site. Then, we'll nee to build a JSP to read form data and set cookies. Then, finally, we have to create our homepage to read the cookies and display the personalized content. All right, a lot of good things in store here. Let's dive in and start writing some code. End of JSP tutorial transcript
