Q 1) Given the following to JSP files select the right answers.
<!-- file container.jsp -->
<html><body>
<%@ include file=”included.jsp” %>
<%@ page errorPage=”OneErrorPage.jsp” %>
</body></htm>
////////// different file
<!-- file included.jsp -->
<html><body>
<%@ page errorPage=”AnotherErrorPage.jsp” %>
<i>Hello</i>
</body></html>
1) File container.jsp will compile if the directive page comes before the directive include
2) File container will compile and when executed it will show:”Hello”.
3) File container.jsp will compile if the errorPage in container.jsp is the same as in file
included.jsp.
4) File container.jsp will compile if instead of directive include (<%@ include ...%>) it is used
the action include (<jsp:include...>)
Q 2) What are correct statements about creating scripting variables for a Tag::
1) It is necessary to implement TagExtraInfo interface.
2) You have to insert into the tag element of the taglib descriptor file an entry for tei-class
element.
3) The interface you have to implement has a method called getVariableInfo.
4) None of the previous.
Q 3) Which of the following staments are correct about the following jsp lines:
<jps:useBean id=”name” class=”java.lang.String” />
<%= name %>
1) It won't compile.
2) It is a valid jsp line and it will print the variable called name.
3) It will compile but it will always produce null as the output.
4) It will work if you create a javabean class with only one variable of type java.lang.String.
Q 4) Given the following jsp line select the correct statements:
<% public void jspInit() { ...java code...} %>
1) It is a valid line that can be used to initialize the servlet that implements the jsp file.
2) It won't compile as no identifer can start with jsp not _jsp.
3) It will serve as the servlet initialization if the function's name is _jspInit.
4) There is no way to initialize a jsp's implementation class servlet.
Q 5) What will be printed out if this jsp code?
<%! java.util.Locale class1=request.getLocale(); %>
<%= class %>
1) It won't compile.
2) It will print the default client's Web browser locale.
3) It will print the default web server Locale.
4) It will the first language specified in the Accept-Language request's header.
Q 6) What will be printed out if this jsp code?
<% java.util.Locale class =request.getLocale() %>
<%= s %>
1) It won't compile.
2) It will print the default client's Web browser locale.
3) It will print the default web server Locale.
4) It won't print the default Locale but the first language specified in the Accept-Language
request's header.
Q 7) What is the return type of the getLastModified method of HttpServlet?
1) java.util.Date
2) java.sql.Date.
3) int.
4) long
Q 8) Which of the following are mandatory elements of the tagLibrary descriptor file?
1) tlib-version
2) jsp-version
3) short-name
4) tag
Q 9) What will be the result of running the following jsp file taking into account that the Web server has
just been started and this is the first page loaded by the server?
<html><body>
<%= request.getSession(false).getId() %>
</body></html>
1)It won't compile
2)It will print the session id.
3)It will produce a NullPointerException as the getSession(false) method's call returns null, cause
no session had been created.
4)It will produce an empty page.
Q 10) What statements are correct about the method PageContext.findAttribute(String name)?
1) There is no such method.
2) It searches the attribute in all 4 scopes.
3) It searches the attribute in page scope.
4) The method is findAttribute(String name, int scope)
Q 11) What are the methods of HttpSessionAttributeEvent?
1) There is no such event
2) getSession()
3) getName()
4) getValue()
Q 12) Which are mandatory elements of the web-resource-collection element?
1) web-resource-name
2) url-pattern
3) http-method
4) auth-constraint
Q 13) Inside the body ( <elemnent>body</element>) of which elements can you use the element
jsp:param?
1) <jsp:include ...>
2) <jsp:forward ...>
3) <jsp:params >
4) <servlet-params...>
14) What are the types returned by the ServletContext method getResource and
etResourceAsStream?
1) ServletContext doesn't have one of these two methods.
2) String and InputStream
3) URL and InputStream
4) URL and StreamReader
15) Which of the following statements regarding HttpRequest methods are correct?
1) getHeaderNames returns an Enumeration
2) getHeaders returns a String[]
3) getHeaderValues returns a String[]
4) getIntParameter returns an int
16) Which of the following is the formal parameter's type that the HttpRequest.setDate
method accepts?
1) java.util.Date
2) java.sql.Date
3) int
4) none of the above
17) Which statements are correct about the method PageContext.include?
1) There is no such method.
2) It has two paramters: request and response
3) It has one parameter of type String which is the relative URL of the page to in
4) This method is appropiate to use within a Tag class.
18) Which of the following statements PageConext methods pushBody and popBody ar
1) pushBody is called by the jsp container after doStartTag and before doAfterBd
2) pushBody is called by the jsp container before doInitBody
3) popBody is called by the jsp container after doAfterBody and before doEndTag
4) popBody is called by the jsp container after doEndTag
19) Is it true that all tags have a parent tag,which is null for top-level tags, and is the i
ontaining tag for nested tags.
1) yes
2) no
3) only the second part of the statement is true.
20) What statements are correct about the method BodyTagSupport.doInitBody.
1) It is a method used by the jsp container and the jsp programmer shouldn't ov
2) It can be overriden if needed.
3) It can return either SKIP_BODY or EVAL_BODY_INCLUDE.
4) Its return type is void.
KEY
A1) 4) File container.jsp will compile if instead of directive include (<%@ include ...%>
action include (<jsp:include ...>)
With directive include (<%@ include file=”fileName” %>) the file is literaly included b
compilation.In this case we have then, two lines with directive page both with attribute
an error. Then only attribute of directive page that can occur more than once is import
A2)
1)It is necessary to implement TagExtraInfo interface.
2)You have to insert into the tag element of the taglib descriptor file an entry for “tei-c
3)The interface you have to implement (TagExtraInfo) has a method called getVariable
A3) 2) It is a valid jsp line and it will print the variable called name.
It will work.To have valid functionality you have to set an attribute of String type in the
before it is accessed by <jsp:useBean ...>
A4) 1) It is a valid line that can be used to initialize the servlet that implements the jsp
A5) 1)It won't compile.
The eight implicit objects in jsp pages are not visible in declarations.They are visible in
expressions.
A6) 1) It won't compile.
You can define a variable with a reserved word.
A7) 4) long
A8)
1) tlib-version
2) jsp-version
3) short-name
4) tag
A9) 2)It will print the session id.
By default jsp pages are part of a session.That's why you have the implicit object sess
this default behaviour with the following line
<%@ page session=”false” %>.
A10) 2) It searches the attribute in page,request,session,application scope in that orde
A11) 1)There is no such event.
There is the HttpSessionBindingEvent event.
A12)
1)web-resource-name
2) url-pattern
A13)
1)<jsp:include ...>
2) <jsp:forward ...>
3) <jsp:params >
A14) 3) URL and InputStream
A15) 1) getHeaderNames returns an
A16) none of the above.
It's long.
A17)
3) It has one parameter of type Stri
4) This method is appropiate to use
A18)
1)pushBody is called by the jsp cont
3) popBody is called by the jsp cont
A19) 1) yes
A20)
2) It can be overriden.
4) Its return type is void.
0 comments:
Post a Comment