Introduction Of the JSP (Java Server Pages)
A web application consists of the presentation and business logic.
Presentation layer- Web Designer
Business Logic- Web Developer
JSP is used to perform Presentation.
What is the presentation layer?
In web site, what are the pages are interacted with the user or client which pages are called UserInterface. Presentation layer is also known as UserInterface.
UserInterface- UI components.
Web designer don’t need to know the business logic. They know HTML pages to design the web pages in terms of the page layout, color, and text.
Presentation logic represents the static content.
Business Logic represents the dynamic content.
A web designer can design the web page by using HTML at the same time the web developer can use java code and other jsp tags to code the business logic. So both web designer and web developer can work independently.
Although we use servlet to perform presentation logic, there are some reasons we use jsp to create presentation logic.
Compiling the jsp page.
A jsp page after compilation generates a servlet and therefore incorporates all servlet functionalities.
Servlet and jsp share common features such as OS(Operating System) independent, create DB web application and server side programming.
Difference Between Jsp And Servlet
Servlet files: combine HTML and servlet( HTML file for the static content and servlet file for dynamic content).
In servlet, a change made to any files, we require to re-compile the servlet.
In jsp, jsp allows java to be embedded directly into an HTML page by using tags. The HTML content and java content can also be placed in separate files. So any changes made to HTML content is automatically compiled and loaded onto the server.
Jsp Life cycle:
When the client browser request for the page, the server sends the request to the JSP engine. JSP engine is part of a web container that compiles a jsp page to servlet.
Once a jsp page is translated to a servet, the container invokes life cycle method.
jspInit(): this method is invoked when the servlet is initialized.
jspService(): this method is invoked when the request for the jsp page is received.
jspDestroy(): this method is invoked before the servlet is removed from the service.
No comments:
Post a Comment