Professional Documents
Culture Documents
BB: Javaserver Pages (JSP)
BB: Javaserver Pages (JSP)
BB: Javaserver Pages (JSP)
(JSP)
ATS Application Programming: Java
Programming
Syntax Summary
JSP Directives
JSP Actions
<%
String queryData = request.getQueryString();
Out.println(“Attached GET
©2004 Accenture data:
All Rights “+
Reserved. 9
© Accenture 2005 All Rights Reserved
JSP Scripting
Scriptlets
Name Description
<% directive attribute=“value” %>
Page Lets you import classes and
customize the Servlet
superclass, and the like.
Includ Lets you insert a file into the
e Servlet class at the
time the JSP file is translated into
a Servlet.
©2004 Accenture All Rights Reserved. 12
© Accenture 2005 All Rights Reserved
JSP Directives
session true (active) / false (disable)
<%@ page session = “true” %>
buffer sizekb (buffer size in Kilobyte) / none
(disable)
autoflush true <%@ (flush buffer) /=false
page buffer “none”(exception)
%>
<%@ page autoFlush = “true” %>
extends extends=“package.class”
<%@ page extends =“com.taglib…” %>
info info = “message”
<%@ page info = “java.com test page,
errorPage errorpage test“%>= “URL”
<%@ page errorPage =
isErrorPa true (error page) / false (no
“/error/error.jsp” %> error page)
ge <%@ page isErrorPage = “true”%>
language language = “java”
<%@ page language = “java” %>
contentTy contentType=”ctinfo”
pe <%@ page contentType = “description”
import import=”importList”
%>©2004 Accenture All Rights Reserved. 13
<%@ page import = “package” %>
© Accenture 2005 All Rights Reserved
JSP Directives
Include:
This directive lets you include files at the
time
the JSP page is translated into a Servlet
<HTML>
<HEAD><TITLE>JavaServer Pages
(JSP) </TITLE>
</HEAD> ©2004 Accenture All Rights Reserved. 14
<BODY>
© Accenture 2005 All Rights Reserved
JSP Actions
JSP Actions are used to control the behavior of
the
Servlet Engine.
• jsp:include - Include a file at the time the page is
requested.
• jsp:useBean - Find or instantiate a JavaBean.
• jsp:setProperty - Set the property of a JavaBean.
• jsp:getProperty - Insert the property of a JavaBean into
the output.
• jsp:forward - Forward the requester to a new page.
• jsp:plugin - Generate browser-specific code that makes
an OBJECT or EMBED tag for the Java plugin.
<CENTER>
<TABLE BORDER=5 BGCOLOR="#EF8429">
<TR><TH CLASS="TITLE">
Using JavaServer Pages</TABLE>
</CENTER>
<P>
<UL>
<LI><B>Expression.</B><BR>
Your hostname: <%= request.getRemoteHost() %>.
<LI><B>Scriptlet. </B><BR>
<% out.println("Attached GET data: " + request.getQueryString()); %>
<LI><B>Declaration (plus expression).</B><BR>
<%! private int accessCount = 0; %>
Accesses to page since server reboot: <%= ++accessCount %>
<LI><B>Directive (plus expression). </B><BR>
<%@ page import = "java.util.*" %>
Current date: <%= new Date () %>
</UL>
</BODY>
</HTML> ©2004 Accenture All Rights Reserved. 16
© Accenture 2005 All Rights Reserved
Example using Scripting &
Output Directives
http://java.sun.com/products/jsp/download.htm
http://java.sun.com/products/jsp
http://www.roseindia.net/jsp/introduction.shtm
http://java.sun.com/developer/onlineTraining/J
©2004 Accenture All Rights Reserved. 18
© Accenture 2005 All Rights Reserved
Questions