Search This Blog

JSP Introduction,What is JSP,JSP Defination:-

JSP means Java server page, JSP provides static web content and dynamic web content both.

using static web content we can design web pages and dynamic web content we can write java programs.

but servlet only contains the dynamic web content.


JSP page by default managed by Web Container internally.  It provides HTML view by default but Servlet has Class View By Default.



In Standard Web programming we will use servlet for business code or program logic and JSP for design interface.


...................................................................................................................................................................


Step to Add JSP in Netbeans IDE Tools:


Create a new Java Web Project ----> Right click on Web Pages and Add JSP Page ,it will provide HTML5 View.


Step to Add JSP in Eclipse IDE Tools:

Create new Java Web Project ----> Right click on WebContent and Add JSP Page ,it will provide HTML5 View.




How we can write a Java Program Code in JSP:-  We will create a scriptlet  block to write java program code.
 <%
            int a=100,b=200,c;
            c=a+b;
            out.print("result is "+c);
           
           
            %>


JSP also has two different block


1)  JSP Declaration Tag or Statement


<!%       int a,b,c;                               %>





2)  JSP Output Tag

<%=       result         %>





3)  JSP Expression Tag or Scriptlet:-


  <%                                                 %>








Program to Create Addition using all tag elements




<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
       
        <%!   int a,b,c;     %>
        <h1>Addition </h1>
        <%
           a=100;
           b=200;
            c=a+b;
         
           
           
            %>
           
            <br>
           
            Result is  <%= c  %>
    </body>
</html>


Post a Comment

If you have any doubt in programming or join online classes then you can contact us by comment .

Previous Post Next Post