scriptlet
                                                            Directives                                          ...
jsp:plugin                                             jsp:setProperty                                              pageCo...
Upcoming SlideShare
Loading in …5
×

Jsp quick reference card

2,096 views
1,994 views

Published on

Jsp quick reference card

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,096
On SlideShare
0
From Embeds
0
Number of Embeds
9
Actions
Shares
0
Downloads
69
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Jsp quick reference card

  1. 1. scriptlet Directives Contains a block of scripting code. A JSP page can contain multiple blocks of scripting code. page <% script code %> Defines page-wide attributes. Example: <%@ page attribute="value" ... %> <% String greeting = request.getParameter("Greeting"); attributes, with default values, are: out.println(greeting); %> JSP Quick Reference Card attribute = language="java" | session="true" | contentType=text/html;charset="ISO-8859-1" expression | import="package(s)" | buffer="8kb" Basic Syntax | autoflush="true" | isThreadSafe="true" Defines statements evaluated on the server before | info="text_string" | errorPage="relativeURL" sending the page output to the client. | isErrorpage="true" | extends="class_name" <%= expression %> Default scripting language value = a string literal in single or double quotes. Example: The scripting language of a JSP page defaults to Java. Insert the following line in a JSP page to configure the include <%= myVar1%> page to use JavaScript: Inserts text into a JSP page. <%@ page language = "javascript" %> <%@ include file = "path" ... %> Actions Using white space taglib jsp:include White space contained within the template code is Defines a custom tag library used by a JSP page. Call one JSP page from another. Upon completion, the returned to the client as it was entered in the JSP. <%@ taglib uri="tagLibraryURI" destination page returns control to the calling page. prefix="tagPrefix" %> Quoting attribute values <jsp:include page="path" flush="true"/> After the taglib directive, reference the custom tags Quote attribute values, using either single or double using the syntax: <jsp:include page="path" flush="true"> quotes, to all JSP elements. For example: <jsp:param name="paramName" <tagPrefix:tagName> value="paramValue" /> ... <%@ page contentType = "text/plain" %> ... </jsp:include> </tagPrefix:tagName> Writing comments for the JSP jsp:forward A JSP comment is not output to the client as part of the Scripting Elements Calls one JSP page from another. Execution of the calling JSP page’s output. page is terminated by the call. <%-- Comment string... --%> declaration <jsp:forward page="path" /> Creates page-wide definitions such as variables. Outputting comments to the client <jsp:forward page="path"> <%! declaration %> <jsp:param name="paramName" HTML comments are output to the client. value="paramValue" /> ... Example: </jsp:forward> <!-- comments --> <%! private String foo = null; public String getFoo() {return this.foo;} %>
  2. 2. jsp:plugin jsp:setProperty pageContext Enables you to invoke an applet on a client browser. Sets the value of one or more properties in a bean. The page context for the JSP. <jsp:plugin <jsp:setProperty name="beanName" prop_expr /> Java type: javax.servlet.jsp.PageContext type="bean|applet" prop_expr has one of the following forms: code="objectCode" request codebase="objectCodebase" property="*" | { align="alignment" } property="propertyName"| The client request. { archive="archiveList" } property="propertyName" param="parameterName"| { height="height" } property="propertyName" value="propertyValue" Java type: javax.servlet.HttpServletRequest { hspace="hspace" } { jreversion="jreversion" } jsp:getProperty response { name="componentName" } { vspace="vspace" } Writes the value of a bean property as a string to the out The response to the client. { width="width" } object. Java type: javax.servlet.HttpServletResponse { nspluginurl="url" } { iepluginurl="url" } > <jsp:getProperty name="name" { <jsp:params> property="propertyName" /> session { <jsp:param name=" paramName" value="paramValue" /> }+ The session object created for the requesting client. </jsp:params> } JSP Objects { <jsp:fallback> arbitrary_text Java type: javax.servlet.http.HttpSession </jsp:fallback> } > See the corresponding Java object type for the available </jsp:plugin> methods for these objects. Allaire Contact Information The elements in brackets ({}) are optional. application jsp:useBean Allaire Web sites The servlet context obtained from the servlet Defines an instance of a Java bean. configuration object. Main Allaire Web site: Java type: javax.servlet.ServletContext www.allaire.com <jsp:useBean id="name" scope="page|request|session|application" JRun Development Center: typeSpec /> config www.allaire.com/developer/jrunreferencedesk/ <jsp:useBean id="name" The ServletConfig object for the JSP page. JRun Developer Forum: scope="page|request|session|application" typeSpec > Java type: javax.servlet.ServletConfig forums.allaire.com/jrunconf body </jsp:useBean> exception Allaire technical support typespec is any one of the following: The uncaught exception that resulted in the error page Telephone support is available Monday through from class="className" | being invoked. Friday 8 AM to 8 PM Eastern time (except holidays). class="className" type="typeName" | Java type: java.lang.Throwable Toll Free: 888.939.2545 (U.S. and Canada) beanName="beanName" type=" typeName" | type="typeName" Telephone: 617.761.2100 (outside U.S. and Canada) out JRun is a trademark of Allaire Corporation. All other trademarks are An object that writes into a JSP page’s output stream. property of their respective holder(s.) © 2000 Allaire Corporation. All rights reserved. Java type: javax.servlet.jsp.JspWriter Part number: AA-JRQRF-RK

×