Please enable JavaScript.
Coggle requires JavaScript to display documents.
JSP (Implicit object
created by the web container (Object : response |…
JSP
Implicit object
- created by the web container
-
-
-
-
-
-
-
-
JSP Scripting
Expression
- <%= expression &>
- evaluated and inserted into the output
- Example :
<%= "Welcome to JSP" %>
Scriptlet
- <% code %>
- inserted into the servlet's service method
- Example :
<% out.print("welcome to jsp"); %>
Declarations
- <%! code %>
- define methods or fields that get inserted into the main body of the servlet class
- Example :
<%! int data=50; %>
<%= "Value of the variable is:"+data %>
JSP Directive
Page
- Import classes & customize the servlet superclass
- The basic syntax of the page directive:
<%@ page attribute = "value" %>
- For example:
<%@ page import="java.util.*" %>
Include
- To include a file during the translation phase
- Merge the content of other external files with the current JSP
- The general usage form:
<%@ include file = "relative url" >
- Example:
<%@ include file = "cart.jsp">
JSP Action
Syntax
- jsp:include
Includes a file at the time the page is requested.<jsp:include page = "relative URL" flush = "true" />
- jsp:useBean
Finds or instantiates a JavaBean.
<jsp:useBean id = "name" class = "package.class" />
- jsp:setProperty
Sets the property of a JavaBean. Need to use two attributes:
<jsp: useBean id = "myname" ... />
<jsp:setProperty name = "myName" property = "someProperty" .../>
- jsp:getProperty
Inserts the property of a JavaBean into the output. Need to use two attributes:
<jsp: useBean id = "myname" ... />
<jsp:getProperty name = "myName" property = "someProperty" .../>
- jsp.forward
Forwards the requester to a new page.
<jsp:forward page = "Relative URL" />
- jsp.plugin
Generates browser-specific code that makes an OBJECT or EMBED tag for the Java plugin.
- jsp:text
Used to write template text in JSP pages and documents.
<jsp:text>Template data</jsp:text>
Definition
- Actions are predefined functions
- There are two common attributes in all action elements: id attribute and scope.
- Example: <jsp:action_name attribute = "value" />