Tutorial Week 6
Tutorial Week 6
Tutorial Week 6
Our readings (lecture notes and video lecture) this week discuss the JSP (Basic JSP, MVC JSP,
JSP Construct). Write the answers for all questions in the table according to your
understanding. PLEASE USE YOUR OWN WORDS. DO NOT COPY FROM THE WEB.
Questions Answers
1. What is the file name extension of a JavaServer page? How is a JSP .JSP
page processed?
2. Where should a JSP file be placed for it to run from Web Server Put it in the html
(Glassfish Server)? file or in the root or
in a subdirectory
below the web
application
3. You can display an HTML file (e.g., c:\test.html) by typing the complete JSP file must be
file name in the Address field of web browser. Why can’t you display a compiled into
JSP file by simply typing the file name? servlets
JSP is a HTML
based code while
servlet is java
based code
5. What are a JSP expression, a JSP scriptlet, and a JSP declaration? JSP expression
How do you write these constructs in JSP? - Used to
insert java
expression
directly into
the output
by using
the <
%=Java-
expression
MMR2022@FSKM
Lecture Assignment
%>
JSP scriplet
-JSP scriplet
enable us to insert
a JAVA statement
into the server
jspService
method, which is
invoke by the
service method by
using th following
form <%java
statement%>
JSP declaration
- Are used
to define
methods
and
instance
using the <
%and%>
delimeters
6. Find THREE syntax errors in the following code: The following code
<%! int k %> missing the “;”
<% for (int j=1; j < =9; j ++) { %>
< %=j; %> <br/> The second code
is incomplete
There is a space
gap between the
“<%”
There should be
opening tag
MMR2022@FSKM
Lecture Assignment
for<br></br>
7. In the following JSP, which variables are instance variables, and which B is instance
are local variables when it is translated into the servlet? variables by using
scriplet while
A is a local
variable by using
declaration
MMR2022@FSKM
Lecture Assignment
8. Write a JSP to display a table that contains factorials for the numbers
from 0 to 10, as shown in below.
MMR2022@FSKM