JaiswalTraining

Get the online training



Corejava Servlet Jsp  Php  Hibernate  Ajax Web Service   Ejb2.1 Ejb3.0 Struts Struts2  JPA Spring Ibatis   JSF    JSF2.0  CoreJavaDesignPattern    Jquery  Flex J2EE-Design-Patterns  Jboss7  Maven  Contact Me                                                                                                                                                                        
            IGNOU SMU PTU Project                                           Training                                                                                                                              
              

Contact Us  0091- 9210721663         jaiswaltraining@gmail.com




Corejava
Servlet
Jsp
Php
Hibernate
Ajax
Web Service
Ejb2.1
Ejb3.0
Struts  
Struts2
JPA
Spring
Ibatis
JSF
JSF2.0
CoreJavaDesignPattern
Jquery
Flex
J2EE-Design-Patterns
Jboss7
Maven








 

JSP Intro and Overview

  • Understanding the need for JSP
  • Evaluating the benefits of JSP
  • Comparing JSP to other technologies
  • Avoiding JSP misconceptions
  • Understanding the JSP lifecycle
  • Installing JSP pages
  • Looking at JSP in the real world

Understanding the need for JSP

When servlet has come in the market that time CGI was prevalent.
But as people started using the servlet they found very comfortable.
It makes web programming easy.It has no complicated syntax as that of the CGI technology.
It also eliminates the server problem prsesnt in CGI technology.

In Servlet programer has to make the class and to add the entries about its description in the web.xml.
But in jsp programer   doesnot need to add the values tothe web.xml. It consists of html page along with simple  Jsp structure.

Jsp technology
  • It is a servlet technology.
  • It is simple than servlet
  • User need not to create any class  file.
  • It allows to use static html/css  with dynamic Servlet generated code
  • Internally it gets converted into the servlet by the Servlet engine.

It has following structures.
  • Simple html  file
  • Css can be used.
  • Javascript can be used
Jsp  elements present are
  • Sriptlet
  • Directive
  • Actions
These elements are embedded into jsp page in the html file.
These gets invoked while  processing of the Jsp page.


Example

  • Create a directory  JspTest
  • Change the  directory to JspTest
  • In the JspTest directory create WEB-INF directory
  • Create a file called Hello.jsp
  • Inside WEB-INF create one file Hello.jsp
   
c:\md JspTest
c:\cd JspTest
c:\JspTest>md WEB-INF\classes
c:\JspTest>notepad WEB-INF\web.xml
c:\JspTest>notepad Hello.jsp


Directory structure is like this.

                       JspTest
                            |
             Hello.jsp |
                            |
                        WEB-INF
           web.xml     |
                             |
                        classes
            
Hello.jsp
<html>
<body>

<h1>Hello jsp world</h1>
<h2>
Today date and time is
<%=new java.util.Date()%>
</h2>

</body>
</html>

web.xml

<web-app>
</web-app>


Deploying the jsp file

  • jsp file can be deployed to any of the web server.
  • Create the war file for it and deploy it on the given server.

c:\JspTest>jar cvf test.war .
c:\JspTest>copy test.war . c:\apache-tomcat-6.0.20\webapps

  • Above  step creates a file called test.war
  • This file contains jsp file along with WEB-INF, web.xml files.
  • In tomcat server webapps  contains the all web application.
  • After copying test.war it gets deployed it there.
  • A test folder gets created containing all the required files.
Running the test.war

  • Open the browser.
  • Give the url http://localhost:8080/test/Hello.jsp
  • The jsp program  will start running here.




How it is work?

  • Client request the jsp file  using the browser.
  • Jsp Engine starts jsp engine over that file
  • Jsp translator converts the jsp file into servlet source file.
  • The Servlet source file is compiled into Servlet class file by the Jsp Engine.
  • Servlet class file is run by the Servlet Engine
  • The output is transferred to the browser by the Web Server


Advantage of  jsp over Servlet

  • As html css is easily embedded so used for the presesntation
  • It requires less XML values to the web.xml
  • It has easy syntax similar to xml
  • It is extensible with Javabeans and Custom Tags