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 going to compare Servlets and JSP. Now, we've seen how we can build applications using JSP so far in the course. We build JSPs to read a request and send back a response. Also, we just learned about how we can use Servlets to read a request and also send back a response, so you may wonder, "Which one should I use? It looks like you can do the same thing with Servlets and JSPs. What's the best practice? What should I do?" Basically, just as a quick recap here, JSPs is really just an HTML file with a .jsp extension. It has some static HTML and also some JSP to generate HTML on the fly as needed. Also, JSPs, as you know, has a collection of built-in JSP objects that you can make use of directly. Now when we look at Servlets, it's really a Java class file, so it's like a helloworldservlet.java. It's a class that extends rewrite methods. We have to write all of the code to generate the HTML. Also, there's some additional steps to access some of the web objects like response.setContentType, response.getWriter, and so on. We have to do a lot of work ourself. In general, it's a little easier to write code using JSPs, but there's still a purpose for Servlets in the architecture. Kind of speaking on that purpose, you may wonder, "Well, which one should I use?" You can use either one for building Java web apps. You can actually build your entire site only using Servlets. I actually did this back in 1998, but Servlets was the first Java server technology that was out. JSPs did not exist, so I actually built an entire site using Servlets for a major client. Or you can build the entire site using JSPs. Now that we have this technology and it's matured a bit, you can actually use them together, and that's the best practice. Here, we can integrate them both together, where we have the Servlet that'll do the business logic, and then the JSP page will handle the presentation view. This is actually a very popular design pattern called the Model-View-Controller Design Pattern, or MVC. This design pattern is used by a lot of the popular Java frameworks like Spring MVC, JSF, Struts, and so on. They're all based on this idea of a Model-View-Controller Design Pattern, and they make use of Servlets and JSPs at the lower level. What I'll do is I'll actually have another section of videos coming up shortly where we'll actually go through the Model-View-Controller Design Pattern in detail. So I'll show you how to set the Servlet up. I'll show you how to have the Servlet talk to the JSP and how the JSP will send data back. We'll get into all the gory details on how to do MVC from scratch with Servlets and JSPs. Anyway, I just wanted to kind of address that issue, because I know a lot of folks always ask the difference between Servlets and JSPs, and I wanted to just address that. What I want to do now is just kind of move forward a bit. We'll focus on Servlets just by itself for the next couple of videos, and then we'll come back and we'll pull it all together with Servlets and JSPs together. So, don't worry. A lot of good things here and a lot of good ground to cover. I'll see you in the next video.
