Skip to main content

Posts

JSP tutorial Part 5:JSP Tags

JSP Tags Tags in Jsp: Tags in JSP can be categorized as -comments -Scripting elements -Directive elements -Action Elements ·          Anything other than the above mentioned four categories fall under template data. ·          This will include all HTML tags and text. JSP Comments: JSP comment marks text or statements that the JSP container should ignore. Following is the syntax of JSP comments: <%-- comment here --%> “Note: in HTMl <!- -comment here   --%> “ JSP Scripting Elements Scripting elements are elements in the JSP page that contains java code. JSP contains 3 types of scripting elements as shown below: 1. Declarations: –Format: <%! code %> –Inserted into the body of the servlet class, outside of any existing methods 2. Expressions: –Format: <%= expression %> –Evaluated and inserted into the servlet’s output i.e., results...

JSP tutorial part 7:Control-Flow Statements

Control-Flow Statements Decision-Making Statements: Theif...else block starts out like an ordinary scriptlet,but the scriptlet is closed at each line with HTML text included between scriptlet tags. <%! int day = 3; %> <html>  <head> <title>if...else example</title> </head> <body> <% if (day == 1 | day == 7) { %> <p> Today is weekend</p> <% } else { %> <p> Today is not weekend</p> <% } %> </body> </html> You can use three basic types of looping blocks in Java: for, while,and do…while blocks in your JSP programming

JSP tutorial part 6:Declaration of variables & methods

Declaration of variables & methods Scripting Elements- Declaration of variables: Variables declared within <% and %> will be local to the service method of the generated servlet and each request will have a separate copy of this variable . <% int data; %> Variable declared within <%! and %> will be a data member of the generated Servlet class and all the requests wil use the same copy of this variable. <%! double amount; %> Scripting Elements-Declaration of methods: o    Methods also can be declared using scripting elements o    All the methods should be declared within <%! And %> and they become a method the generated Servlet. JSP Declarations: We can declare more than one variable using the following syntax: <%! declaration; [ declaration; ] ... %> Ex. <%! inti= 0; double j=0.0; %> <%! inta, b, c; %> <%! Circle a = new Circle(2.0);%> Ex. <H1>Some Heading</H1> <%! private String randomHeading(...

Java Server page part 4:A Simple Java Server Page

A Simple Java Server Page Dynamic Web Project : JspBasicProject: basic.jsp <%@ page language=”java” contentType=”text/html;charset=ISO-8859-I” pageEncoding=”ISO-8859-I”%> <!DOCTYPE html PUBLIC”-//w3c//DTD HTML 4.01 Transitional//EN” “ http://www.w3.org/TR/html4/loose.dtd ”> <html> <head> <meta http-equiv=”content-Type” content=”text/html;charset=ISO-8859-I”> <title>Sample JSP</title> </head> <body> <h1>Sample Java Server Page</h1> <%   for(int i=10;i>0;i--){ out.println(“<h”+i+”>+”welcome to JSP”+”</h”+i+”>”); } %> </body> </html> “A scriptlet is a fragment of java code which is placed within delimiters and is executed when the user requests for the page .” Uses of JSP Constructs • Scripting elements calling servlet code directly  • Scripting elements calling servlet code indirectly (by means of utility classes)  • Beans • Servlet/JSP combo (MVC 2 Architectu...

Mobile Specification

Lenovo moto g4 plus     vivo v1     Redmi Note3     Le 1s     Lenovo Vibe p1     lenovo sisley s90     samsung galaxy j5     lava pixel v1     Asus fonepad 7     moto G3     Asus Zenfone 2   Blackberryz10     Lenovo Zuk Z1

Java Server page tutorial part 3: JSP Life Cycle

JSP Life Cycle: A JSP life cycle can be defined as the entire process from its creation till the destruction which is similar to a servlet life cycle with an additional step which is required to compile a JSP into servlet. Following are the steps followed by a JSP Container: ◦ Compilation  ◦ Parsing the JSP.  ◦ Turning the JSP into a servlet.  ◦ Compiling  the servlet.  ◦ Initialization ◦ Execution ◦ Cleanup Architecture: 1.       JSP Compilation: When a browser asks for a JSP, the JSP engine first checks to see whether it needs to compile the page.  If the page has never been compiled, or if the JSP has been modified since it was last compiled, the JSP engine compiles the page. The compilation process involves three steps: ◦ Parsing the JSP. ◦ Turning the JSP into a servlet.  ◦ Compiling the servlet.  2.       JSP Initialization: When a container loads a JSP ...