1 / 10

Java Server Pages - Programming

Java Server Pages - Programming. <html<title>JSP code</title><body><% int sum = 0; for( int i = 0; i < 10; i )sum = i; out.print( "the sum is " sum );%></body></html>. JSP ? using classes. <html<title>JSP code</title><body><% java.util.Date d1 = new java.util.Date( ); out.print( d1 )

collin
Download Presentation

Java Server Pages - Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


    1. Java Server Pages - Programming Can have Java code between the tags <% // and %>

    2. Java Server Pages - Programming <html<title>JSP code</title><body> <% int sum = 0; for( int i = 0; i < 10; i++) sum += i; out.print( "the sum is " + sum ); %> </body></html>

    3. JSP – using classes <html<title>JSP code</title><body> <% java.util.Date d1 = new java.util.Date( ); out.print( d1 ); %> </body></html>

    4. JSP – Using classes Instead of using the full path for a class java.util.Date We can import the class with a page directive <%@ page import = "java.util.Date" %> There can be any number of page directives within a JSP page

    5. JSP – Directives JSP directives are enclosed between <%@ and %> The 2 primary directives are Page directive ? used primarily for import statements Include directive ? used for including files

    6. JSP – Using classes <html<title>JSP code</title><body> <%@ page import = "java.util.Date" %> <% Date d1 = new Date( ); out.print( d1 ); %> </body></html>

    7. JSP – Using classes We can import more than one class Use a comma separated list of classes that you want to import <%@ page import = "java.util.Date, java.util.StringTokenizer" %>

    8. JSP – Using classes <html<title>JSP code</title><body> <%@ page import = "java.util.Date, java.util.StringTokenizer" %> <% Date d1 = new Date( ); out.print( d1 + "<br><br>"); StringTokenizer st = new StringTokenizer( "apple pear nut kiwi" ); int num = st.countTokens( ); out.print( "There are " + num + " tokens” ); %> </body></html>

    9. JSP – Using classes We can use several page directives to import classes <%@ page import = "java.util.Date" %> <%@ page import = "java.util.StringTokenizer " %>

    10. JSP – Using classes We can use a bulk import statement in a page directive to import all the classes needed from a given package <%@ page import = "java.util.*" %>

More Related