INTRODUCTION TO JSP

Introduction To Jsp-Free PDF

  • Date:24 May 2020
  • Views:38
  • Downloads:0
  • Pages:23
  • Size:632.52 KB

Share Pdf : Introduction To Jsp

Download and Preview : Introduction To Jsp


Report CopyRight/DMCA Form For : Introduction To Jsp


Transcription:

These problems associated with servlets are due to one and only one reason that is servlet has. to handle all tasks of request processing JSP is a technology that came up to overcome these. Jsp is a technology in which request processing business logic and presentations are. separated out,Request processing Servlet with request. handling class,Processing,Presentation,JSP with some GUI. Pure Servlet Business logic,Anatomy of JSP Core Java code for. implementation of logic,ANATOMY OF JSP PAGE, JSP page is a simple web page which contains the JSP elements and template text. The template text can be scripting code such as Html Xml or a simple plain text. Various Jsp elements can be action tags custom tags JSTL library elements These. JSP elements are responsible for generating dynamic contents. K Yellaswamy AssistantProfessor CMR College of Engineering Technology. E mail toyellaswamy gmail com,Anatomy of JSP,page import java util Date JSP Element.
title Template Text,first jsp program title,out println Hello BTech CSE Students. JSP Element,out println br br,out println Welcome to Jsp Programming. out println new Date toString,center Have a nice Day center. br br Tempalte Text, When JSP request gets processed template text and JSP elements are merged together and. sent to the browser as response,JSP Processing, JSP pages can be processed using JSP Container only Following are the steps that need.
to be followed while processing the request for JSP page. K Yellaswamy AssistantProfessor CMR College of Engineering Technology. E mail toyellaswamy gmail com, Client makes a request for required JSP page to server The server must have JSP. container so that JSP request can be processed For instance let the client makes. request for xyz jsp page, On receiving this request the JSP container searches and then reads the desired JSP. page Then this JSP page is converted to corresponding servlet. Basically any JSP page is a combination of template text and JSP elements. Every template text is converted to corresponding println statement. Every JSP element is converted into corresponding Java code. This phase is called Translation phase output of it is a servlet for instance xyz jsp is. converted to xyzservlet java,The out println html,head out println head. This servlet is compiled to generate servlet class file Using this class response is. generated This phase is called request processing phase. The Jsp container thus executes servlet class file. A requested page is then returned to client as response. Jsp container Xyz jsp,Request xyz jsp reads,Translation phase. generates Xyzservlet java,Request Processing Phase.
Xyzservlet class,Response is sent to client, K Yellaswamy AssistantProfessor CMR College of Engineering Technology. E mail toyellaswamy gmail com,JSP Application design with MVC. The design model of JSP application is called MVC model MVC stands for Model View. Controller The basic idea in MVC design model is to separate out design logic into 3 parts. modelling viewing controlling, Any server application is classified in 3 parts such as business logic presentation and. request processing, The business logic means coding logic applied for manipulation of application data. Presentation refers to code written for look and feels of web page like background color. font size etc, Request processing is combination of business logic and presentation.
According to MVC model,Model corresponds to business logic. View corresponds to presentation,Controller corresponds to request processing. Advantages of using MVC design model, The use of MVC architecture allows developer to keep the separation between business logic. and request processing Due to this separation it becomes easy to make changes in. presentation without disturbing business logic The changes in presentation are often required. for accommodating new presentation interfaces,Setting up JSP environment. For executing any JSP we require,Java Development Kit.
Any web server such as Apache Tomcat,Installing JDK. JDK can be downloaded from oracle website on to our machine After downloading we can. install jdk as, K Yellaswamy AssistantProfessor CMR College of Engineering Technology. E mail toyellaswamy gmail com, Double click on file download option And you will get license agreement window Click on. I Accept and then Next,Then the setup screen will appear as follows. Here we can change default downloading directory to required location Click on Next. After installing JDK further Java Runtime Environment will be downloaded. K Yellaswamy AssistantProfessor CMR College of Engineering Technology. E mail toyellaswamy gmail com, After this installation will be completed and following screen will appear.
Now we have to set up environment variables after java is installed in our PC. Control panel System Properties Advanced,Environment variables. Create a new variable path with its value as location where bin directory of JDK is located. Now JDK is successfully installed,INSTALLATION OF TOMCAT. We can download tomcat from tomcat apache org,Installation process is as. When we download tomcat and click on installer following screen appears Click on Next. K Yellaswamy AssistantProfessor CMR College of Engineering Technology. E mail toyellaswamy gmail com,Accept terms by clicking I Agree. We can choose components to be installed and click on Next. Now installation directory can be chosen We can change default path by clicking on. Browse and selecting location, K Yellaswamy AssistantProfessor CMR College of Engineering Technology.
E mail toyellaswamy gmail com, Now by clicking on Next we get configuration window Here we can set connector port. Default port is 8080 but we can set other values also excluding first 1024 values. We can also set username and password for administrator login Then click Next button. Then installation process will start, K Yellaswamy AssistantProfessor CMR College of Engineering Technology. E mail toyellaswamy gmail com, Click on Finish and installation procedure gets completed. Setting up JAVA HOME variable,Go to Control panel System Advanced tab. Environment Variables Create a new variable JAVA HOME with value as the location. where jdk is installed, K Yellaswamy AssistantProfessor CMR College of Engineering Technology.
E mail toyellaswamy gmail com, Now click on startup bat batch file and start Tomcat server. K Yellaswamy AssistantProfessor CMR College of Engineering Technology. E mail toyellaswamy gmail com,Java Server pages, JSP technology is used to create web application just like Servlet technology It can be. thought of as an extension to servlet because it provides more functionality than servlet such. as expression language jstl etc, A JSP page consists of HTML tags and JSP tags The jsp pages are easier to maintain than. servlet because we can separate designing and development It provides some additional. features such as Expression Language Custom Tag etc. Advantage of JSP over Servlet, There are many advantages of JSP over servlet They are as follows. 1 Extension to Servlet, JSP technology is the extension to servlet technology We can use all the features of servlet in.
JSP In addition to we can use implicit objects predefined tags expression language and. Custom tags in JSP that makes JSP development easy. 2 Easy to maintain, JSP can be easily managed because we can easily separate our business logic with. presentation logic In servlet technology we mix our business logic with the presentation. 3 Fast Development No need to recompile and redeploy. If JSP page is modified we don t need to recompile and redeploy the project The servlet. code needs to be updated and recompiled if we have to change the look and feel of the. application,4 Less code than Servlet, In JSP we can use a lot of tags such as action tags jstl custom tags etc that reduces the. code Moreover we can use EL implicit objects etc, K Yellaswamy AssistantProfessor CMR College of Engineering Technology. E mail toyellaswamy gmail com,Life cycle of a JSP Page. The JSP pages follows these phases,Translation of JSP Page.
Compilation of JSP Page, Classloading class file is loaded by the classloader. Instantiation Object of the Generated Servlet is created. Initialization jspInit method is invoked by the container. Reqeust processing jspService method is invoked by the container. Destroy jspDestroy method is invoked by the container. K Yellaswamy AssistantProfessor CMR College of Engineering Technology. E mail toyellaswamy gmail com,ANATOMY OF JSP PAGE, JSP page is a simple web page which contains the JSP elements and template text. The template text can be scripting code such as Html Xml or a simple plain text. Various Jsp elements can be action tags custom tags JSTL library elements These. JSP elements are responsible for generating dynamic contents. Anatomy of JSP,page import java util Date JSP Element. title Template Text,first jsp program title,out println Hello BTech CSE Students. JSP Element,out println br br,out println Welcome to Jsp Programming.
out println new Date toString,center Have a nice Day center. br br TempalteText, When JSP request gets processed template text and JSP elements are merged together and. sent to the browser as response,JSP Processing, JSP pages can be processed using JSP Container only Following are the steps that need. to be followed while processing the request for JSP page. Client makes a request for required JSP page to server The server must have JSP. container so that JSP request can be processed For instance let the client makes. request for hello jsp page, On receiving this request the JSP container searches and then reads the desired JSP. page Then this JSP page is converted to corresponding servlet. Basically any JSP page is a combination of template text and JSP elements. Every template text is converted to corresponding println statement. Every JSP element is converted into corresponding Java code. K Yellaswamy AssistantProfessor CMR College of Engineering Technology. E mail toyellaswamy gmail com, This phase is called Translation phase output of it is a servlet for instance hello jsp is.
converted to hello jsp java,The out println html,head out println head. This servlet is compiled to generate servlet class file Using this class response is. generated This phase is called request processing phase. The Jsp container thus executes servlet class file. A requested page is then returned to client as response. Model View Controller Architecture,Model is used for Buisness Logic. Example Javabean EJB,View is used for Presentation Logic. Example HTML JSP,Controller is used for RequestProcessing. Example Servlet, K Yellaswamy AssistantProfessor CMR College of Engineering Technology.
Various Jsp elements can be action tags custom tags JSTL library elements These JSP elements are responsible for generating dynamic contents Anatomy of JSP JSP Element Template Text JSP Element gt TempalteText When JSP request gets processed template text and JSP elements are merged together and sent to the browser as response

Related Books