1 / 34

Servlet Tutorial | JSP Tutorial | Advanced Java Tutorial | Java Certification Training | Edureka

**** Java Certification Training: https://www.edureka.co/java-j2ee-soa-training ****<br>This Edureka tutorial on u201cServlet and JSP tutorialu201d will talk about the basics of the World Wide Web and its components. It will tell you the fundamental concepts of servlets and JSP, its life cycle and various steps to create Servlet and Java Server Pages. Also, it will talk about Session Tracking and JSP Request and Response Methods. Through this tutorial you will learn the following topics:<br><br>Web & HTTP <br>Servlet Life Cycle<br>Steps to create Servlet<br>Generic Servlet<br>Session Tracking<br>Introduction to JSP<br>JSP Life Cycle-<br>JSP Scripting and Directive Elements<br>Java Bean Class<br>Check out our Java Tutorial blog series: https://goo.gl/osrGrS<br><br>Check out our complete Youtube playlist here: https://goo.gl/gMFLx3<br><br>Follow us to never miss an update in the future.<br><br>Instagram: https://www.instagram.com/edureka_learning/<br>Facebook: https://www.facebook.com/edurekaIN/<br>Twitter: https://twitter.com/edurekain<br>LinkedIn: https://www.linkedin.com/company/edureka

EdurekaIN
Download Presentation

Servlet Tutorial | JSP Tutorial | Advanced Java Tutorial | Java Certification Training | Edureka

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  2. Topics to be covered Introduction to JSP Introduction to Web 01 05 Introduction to Servlets Steps to create JSP 02 06 Generic Servlets JSP Scripting & Directive Elements 03 07 Session Tracking 04 Java Bean Class 08 JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  3. Introduction to WEB

  4. Web & HTTP JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  5. Web & HTTP HTTP is a protocol that clients and servers use on the web to communicate. JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  6. HTTP Request & Response HTTP Request is a packet of Information that one computer sends to another computer to communicate something Server Client HTTP Request HTTP Response HTTP Response is the packet of information sent by Server to the Client in response to an earlier Request made by Client JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  7. Introduction to Servlets

  8. What are Servlets? Robust & Scalable Creates Web Application Deployed to create Web Page Provides Interfaces & Classes Responds to any incoming requests Must be implemented to create Servlet JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  9. What are Servlets? Server Client Request Response is sent to client Response is generated at runtime JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  10. Servlet Life Cycle Loading & Instantiation Start init() Initialized End of Request thread service() Handling Request destroy() End Stop JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  11. Steps to create Simple Servlet 1 Create and compile simple servlet code 2 Add mappings to web.xml file 3 Start Apache Tomcat 4 Start Web Browser & Request Servlet JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  12. Generic Servlet

  13. Generic Servlet It has a very simple life cycle methods A generic servlet is a Generic Servlet is easier to write protocol independent Servlet that should always To write Generic Servlet you just need to extend javax.servlet.GenericServlet and override the service() method override the service() method to handle the client request.. Pros JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  14. Servlet Classes & Interfaces Declares life cycle method of servlet Servlet Allows servlet to get Initialization methods ServletConfig Enables servlet to log access and access information ServletContext Used to read data from client request ServletRequest Used to write data to client response ServletResponse Implements servlet and Servlet.Config Interface GenericServlet Provides input stream to read requests from the client ServletInputStream Provides output stream to write responses to the client ServletOutputStream Indicates servlet error has occured ServletException Indicates servlet is not available UnavailableException Provides methods to handle Http Request and Response HttpServlet Enables servlets to read data from Http Request HttpServletRequest Enables servlets to write data to Http Response HttpServletResponse JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  15. Session Tracking

  16. Session Tracking in Servlets Session tracking is a way to maintain state(data) of an user 3. Second new request 1. Request(new) 2. Response Client Server JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  17. Hidden form field Cookies Http session URL rewriting JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  18. Cookies in Servlet It is a small piece of information that is persisted between the multiple client requests 2. Request + Cookies 1. Request 3. Response + Cookies JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  19. Useful Methods of Cookie Class Sets the maximum age of the cookies in seconds public void setMaxAge(int expiry) Returns the name of the cookie. Name cannot be changed after creation public String getName() Returns the value of the cookie public String getValue() Changes the name of the cookie public void setName(String name) Changes the value of the cookie public void setValue(String value) JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  20. Creating & Deleting a Cookie 1.Cookie ck=new Cookie("user",“Edureka");//creating cookie object Creation 2.response.addCookie(ck);//adding cookie in the response 1.Cookie ck=new Cookie("user","");//deleting value of cookie 2.ck.setMaxAge(0);//changing the maximum age to 0 seconds 3.response.addCookie(ck);//adding cookie in the response Deletion JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  21. Introduction to jsp

  22. What is JSP? It is used to create web application just like Servlet technology. Also called as extension of servlet Portable Fast Development Powerful Tracking User Flexible Easy to maintain JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  23. Advantages of JSP over Servlets JSP ▪ Extension to Servlet ▪ It is not a extension of JSP ▪ Easy to maintain ▪ Bit complicated ▪ No need to recompile and redeploy ▪ Code needs to be recompiled ▪ Less code than servlet ▪ More code comparatively Servlets Operation JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  24. Life Cycle of JSP Buffer JSP (dynamic content) JSP Translator Servlet Object Servlet (.java File) JRE Compiler Class file JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  25. Steps to create jsp

  26. Steps to create JSP Page 1 Create dynamic web project 2 Create JSP File 3 Start Apache Tomcat 4 Deploy the project and get the output JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  27. Jsp Scripting & Directive elements

  28. JSP Scripting Elements scriptlet <% java source code %> expression <%= statement %> declaration <%! field or method declaration %> JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  29. Implicit Objects of JSP out Jspwriter request HttpServletrequest response HttpServletResponse config ServletConfig application ServletContext session HttpSession pageContent PageContext page Object exception Throwable JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  30. JSP Directive Elements <%@ page directive="value” %> Page directive Include directive <%@ include file="resourceName" %> Taglib directive <%@ taglib uri="uriofthetaglibrary" prefix="prefixoftaglibrary" %> JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  31. Java bean class

  32. Java Bean Class It is a reusable software component. A bean encapsulates many objects into one object, so we can access this object from multiple places. Moreover, it provides the easy maintenance. 1.<jsp:useBean id= "instanceName" scope= "page | request | session | application" 2.class= "packageName.className" type= "packageName.clas sName" 3.beanName="packageName.className | <%= expression >" > 4.</jsp:useBean> JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

More Related