Shared Flashcard Set

Details

JSP Technology (Chapter 11)
JSP Technology (Chapter 11)
35
Computer Science
Undergraduate 4
07/04/2007

Additional Computer Science Flashcards

 


 

Cards

Term
<% String s = s1 %>
<%! String s1 = "hello"; %>

Will this compile?
Definition
No because since scriptlets become
part of the _jspService () , the variables declared become local variables, so order is important.
Term
<%! int i; !%> (glob)
<% int j; %> (loc)
The value of i is <%= i++ %> 1
The value of j is <%= j++ %> 2
Which line will cause an error and why?
Definition
line 2 because j is not initailized,
since instance variables are intilized by default,
while local variables like in line2
are not.
Term
<%! is an example of

1. delcaration
2. scriptlet
3. expression
Definition
1. delcaration
Term
<% is an example of

1. delcaration
2. scriptlet
3. expression
Definition
2. scriptlet
Term
<%= is an example of

1. delcaration
2. scriptlet
3. expression
Definition
3. expression
Term
Is this a valid JSP construct
<%=myObj.m1(); %>
Definition
INvalid because the sign = makes it a JSP Expression, and they should never be terminated with a semicolon.
Term
Is this valid?
<% int x= 4, y = 5; %>
<%=x=y%>
Definition
Yes it is valid.
translated to out.print(x=y)
Term
What is wrong with the following?
<%@ page language='java' %>
<% int x= 0;
int incr() { return ++x; }
%>
Definition
Can't define methods in a scriptlet. Upon translation the _jspService will had the method inside _jspService() which is illegal
Term
1. <% int x = 3; %>
2. <%! int x = 5; %>

Which declaration is local to the class?
Definition
1
Term
The implicit variable available to JSP page that belongs to interfac javax.servletServletContext is....
Definition
application
Term
The implicit variable available to JSP page that belongs to interface javax.servlet.http.HttpSession....
Definition
session
Term
The implicit variable available to JSP page that belongs to interface javax.servlet.http.HttpServletRequest....
Definition
request
Term
The implicit variable available to JSP page that belongs to interface javax.servlet.http.HttpServletResponse....
Definition
response
Term
The implicit variable available to JSP page that belongs to class
javax.servlet.jsp.JspWriter....
Definition
out
Term
The implicit variable available to JSP page that belongs to class
java.lang.Object
Definition
page
Term
The implicit variable available to JSP page that belongs to class
javax.servlet.jsp.PageContext
Definition
pageContext
Term
The implicit variable available to JSP page that belongs to class
java.lang.Throwable....
Definition
exception
Term
The implicit variable available to JSP page that belongs to interface
javax.servlet.ServletConfig....
Definition
config
Term
________ pageContext = null;
Definition
PageContext
Term
_____ session = null;
Definition
HttpSession
Term
_______ application = null;
Definition
ServletContext
Term
_______________ config = null;
Definition
ServletConfig
Term
___________ out = null;
Definition
JspWriter
Term
___________ out = null;
Definition
JspWriter
Term
application variable

String path = application.getRealPath("")
same as
String path =__________.getRealPath
Definition
getServletContext()
Term
<%@page session ="false" %>
Session ID = <%session.getId()%>

compile?
Definition
no because session = false indicates that the current page will not participate in an HTTP session, so the implicit variable session is unavailable.
Term
String remoteAddr = ____getRemoteAddr();

Request or Response?
Definition
request.getRemoteAddr();
Term
__.setContentType("text/html...");

Response or Request?
Definition
response
Term
Which will compile?

<%= page.getServletInfo() %>
<% this.getServletInfo() %>
Definition
<% this.getServletInfo() %>
because page is a class of java.lang.Object so it cannot be used to directly call the servlet methods.
Term
The four scopes of object in JSP pages
are
1. Application
2. Session
3. Request
4. __________
Definition
Page
Term
Objects in which scope are accessible to all of the web applications of a servlet container?
Definition
There is no scope that can
share objects across mutliple web applications. To do that, we have to either use
SErvlet Context.getContext() or use an external database.
Term





What is wrong with the above?
Definition
Expression and Declaration
should be lower case.
(case sensitive)
Term
Static includsion, the contnets of another file are included we use include.


How to write this JSP style?
Definition
<%@ include file="link" />
Term
In dynamic includsion, when the JSP page is requested, it sends a request to another object, and the output from that object is included in the requested JSP page. We use which 2 actions?
Definition
and
Term
Using jsp:forward

1. RequestDispatcher rd = request.getRequestDispatcher('o.jsp");
rd.forward(request, response)

HOw can we write this another way?
Definition
1. pageContext.forward('"o.jsp");

2.
Supporting users have an ad free experience!