Jsp Syntax Examples

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Jsp Syntax Examples as PDF for free.

More details

  • Words: 443
  • Pages: 3
JSP Syntax card with examples Element

JSP Style

Comment

<%--

Declaration

<%! int x=0; boolean bBool = false; %>

Expression

<%= bool %> Any java primitive or string etc.

Scriptlet

Text

<% java code fragment; %> Nil

Include Directive

<%@ include file=”myPage.jsp” %>

Page Directive

<%@ page language=’java’ | import=’com.neon.pack.*’ | session=’true’ | ‘false’ buffer=’none’ | ‘8kb’ autoflush=’true’ | ‘false’ isThreadSafe=’true’ | ‘false’ info=’blah’ errorpage=’errro_blah.jsp’ isErrorPage=’true’ | ‘false’ %> <%@ taglib uri=’/tagdir/myTag.tld’ prefix=’me’ %>

bold = default

Taglib Directive

Tag usage

<jsp:forward>

<jsp:getProperty> <jsp:include>

comment here

XML Style ---%>

<me:tester year=’2003’ /> <me:tagger age=’38’ > jsp body -- -- - <jsp:forward page=’myPage.jsp’ /> <jsp:forward page=’<%= expression %>’ /> <jsp:forward page=’myPage.jsp’ > <jsp:param name=’age’ value=’39’ /> <jsp:param name=’age’ value= ‘<%= expression %>’ /> <jsp:getProperty name=’addressBean’ property=’zip’ /> <jsp:include page=’myPage.jsp’ flush=’true|false’ /> <jsp:include page=’<%= expression %>’ flush=’true|false’ />

Nil <jsp:declaration> int x=0; boolean bBool =false; <jsp:expression> bool <jsp:scriptlet> java code fragment; <jsp:text> free flowing text <jsp:directive.include file=” myPage.jsp” /> <jsp:directive.page language=’java’ | import=’ ’com.neon.pack.*’ | session=’true’ | ‘false’ buffer=’none’ | ‘8kb’ autoflush=’true’ | ‘false’ isThreadSafe=’true’ | ‘false’ info=’blah’ errorpage=’errro_blah.jsp’ isErrorPage=’true’ | ‘false’ /> <jsp:root xmlns:jsp=’http://java.sun.com/jsp/page’ à xmlns:me=’/taglib/myTag.tld > -- -- --- -- - -- same as jsp --

<jsp:forward page=’myPage.jsp’ /> <jsp:forward page=’%= expression %>’ /> <jsp:forward page=’myPage.jsp’ > <jsp:param name=’age’ value=’39’ /> <jsp:param name=’age’ value= ‘<%= expression %>’ /> <jsp:getProperty name=’addressBean’ property=’zip’ /> -- same --<jsp:include page=’%= expression %’ flush=’true|false’ /> -- same ---

<jsp:include page=’myPage.jsp’ > <jsp:param name=’street’ value=’Goddard’>



<jsp:useBean>

<jsp:include page=’myPage.jsp’ > <jsp:param name=’street’ value= ‘<%= expression %>’ />

<jsp:include page=’myPage.jsp’ > <jsp:param name=’street’ value= ‘%= expression %’ />

<jsp:useBean id=’objAddress’ scope=’page’

-- same --

class=’com.neon.OfficeAddressBean’ type=’com.neon.AddressBean’ />

<jsp:setProperty>

<jsp:useBean beanName=’addressBean type=’com.neon.Address’ ’ / > <jsp:useBean beanName=’<%= exprr >’ type=’com.neon.Address’ ’ / > <jsp:setProperty name=’objBeanName’ property=’*’> <jsp:setProperty name=’objBeanName’ property=’city’ param=’myCity’ />

<jsp:setProperty name=’objBeanName’ property=’city’ value=’Bracknell’ />

jsp:plugin

<jsp:setProperty name=’objBeanName’ property=’city’ value=’<%=expr%>’ /> <jsp:plugin Compulsory elements type=’bean | applet’ code=’class file name’ codebase=’class file dir name’ Optional elements name archive align height width hspace jreversion nspluginurl iepluginurl > <jsp:params> <jsp:param name=’namer’ value=’val’> <jsp:fallback> message

An area of confusion is when to use the include directive instead of the include action and vice versa. Include Directive <%@ include file= ‘myPage.jsp’ %> Translation time Fast File changes rarely

Actual file is included The 2 pages might not compile independently The variables can be shared

Produced by Yogen Joshi for VisualBuilder.com

Include Action <jsp:include page=’myPage.jsp’ /> Request time Slow File changes quite often Response of the included file is included The 2 files can [should] compile independently Variables between the 2 pages can be shared only through Different scopes e.g. context, session, request,etc.

Related Documents

Jsp Syntax Examples
November 2019 10
Jsp Syntax
November 2019 27
Syntax
May 2020 13
Jsp
April 2020 36
Jsp
May 2020 27