Uploaded on

 

More in: Education , Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
153
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
20
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. J2EE
  • 2. Introduction ● Q. What is J2EE ? Java platform to developing enterprise web application
  • 3. Basic Architecture
  • 4. Description ● J2EE architecture : 3 tier – Client Tier ( Web tier) ● – Business Tier ● – The Presentation layer on the client side includes j2ee componenets such as jsp,jsf etc Components containing business logic of the application such as Enterprise Beans. Database Tier ● This tier contains the persistence API of the application so as to talk to database
  • 5. Java Web Components ● Servlet ● Jsp ( Java Server Pages ) ● Jstl (Jsp Standard Tag Library) ● Jsf ( Java Server Faces )
  • 6. Servlet ● Extends web server's functionality ● Respond to Request from client ● Used to generate dynamic response ● Usually responses in HTML or Xml format ● Most often used with HTTP protocol
  • 7. Functioning of Servlet ● ● ● Process or Store data that was submitted by HTML forms Provide dynamic content such as the result of a database query Manage State information (in case of stateless HTTP protocol)
  • 8. Packages (imports) for Servlet ● java.io.*; – ● javax.servlet – ● Input and Output package (eg. Out.println) Contains interaction logic between web container and servlet javax.servlet.http – Contains Http specific logic
  • 9. ● javax.servlet.http.HttpServletRequest; ● javax.servlet.http.HttpServletRespons
  • 10. Servlet Skeleton ● Imports ● Public classname extends HttpServlet – Public void init() ● – Public void Service() ● – { /* Initialization goes here */ } {/* Business logic goes here */ } Public void destroy() ● {/* Free resources here */}
  • 11. Lifecycle ● Loaded and Instantiated ● Initialization ● Servicing the request ● Destroying the request
  • 12. ● Loaded and instantiated – ● Container loads servlet during startup or when the request is made. After loading the servlet , the container creates the instance of the servlet when the first request come for service , Initialization – After creating the instance the container calls init() method. The init method is called only once in servlets lifetime. Initialization logic goes here
  • 13. ● Servicing the request – After successful initialization , servlet will be available to serve the request. Servlet creates separate thread for each request – Service() method is called to serve the request in short service method contains the business logic
  • 14. ● Destroying the servlet – If the servlet is no longer needed , the servlet container calls the destroy() method. – Like the init() method destroy() method also get called only once in servlet's lifetime – Destroy() method releases all the resources which were acquired previously
  • 15. JSP (Java Server Pages) ● Jsp is a component which generates dynamic contents ● Jsp is a server-side technology ● Extension : .jsp ● Jsp usually consist of two components – Static Data ● – Can be expressed in any text based format such as HTML JSP elements ● Jsp tags , which can generates dynamic contents
  • 16. JSP Components ● Declaration tag ● Scriptlet tag ● Expression tag ● Directive tag ● Action tag
  • 17. ● Declaration tag: – Declaration is used to declare and define java variables and methods inside your jsp – They are initialized when the jsp page is initialized – The scope of the declared variables or methods is within the jsp page – Syntax : <%! int a = 10; %>
  • 18. Declaration Example : <html> <body> <%! int value = 10; %> Hello World!<%= value %> </body> </html>
  • 19. ● Scriptlet tag: – Scriptlets are block of java code – You can write any number of java code inside your jsp using scriptlet – Syntax : <% ( Java Code ) %>
  • 20. Scriptlet Example : <html> <body> Hello World! <% out.println("Helloworld"); %> </body> </html>
  • 21. ● Expression tag: – The code placed inside expression tag is printed (output) , so there is no need to write out.println() – Mainly used to print values of variables and methods – Syntax : <%= (variable or method) %>
  • 22. Expression Example : <html> <body> <%! int value = 10; %> Hello World! <%= value %> </body> </html>
  • 23. ● Directive tag: – Jsp directive provide directions and instructions to the container , how to handle certain jsp processing – There are 3 types of directives ● ● ● Page directive Include directive Taglib directive
  • 24. – Page directive ● ● ● Page directive is used to provide information about the page Example : <%@page language="java" %> Here language is an attribute of the page directive
  • 25. – Include directive ● ● ● Include is used to include a jsp file in the jsp page Example : <%@ include file="/header.jsp" %> File is an attribute which specifies which file need to include
  • 26. – Taglib directive ● ● ● Taglib directive is used to use the custom tags in the jsp page ( custom tags allow us to define our own tags ) Example : <%@ taglib uri="tlds/taglib.tld" prefix="mytag" %>
  • 27. ● Action tag: – The action tag basically are used to control the flow between pages and to use Java Beans
  • 28. – Some of the action tags are ● ● ● ● ● ● ● ● Jsp:forward Jsp:include Jsp:useBean Jsp:setProperty Jsp:getPropery Jsp:plugin Jsp:param Jsp:fallback