Adv Java
Adv Java
Adv Java
getServletContext().getAttribute("name");
getApplication().getAttribute("name");
bodyContent.getApplicationAttribute("name");
pageContext.getAttribute("name",PageContext.APPLICATION_SCOPE);
If the doStartTag() method returns EVAL_BODY_BUFFERED one time and the doAfterBody() method
returns EVAL_BODY_BUFFERED five times, how many times will the setBodyContent() method be
called? Assume that the body of the tag is not empty.
Two
One
Five
Zero
Which of the following are the benefits of using the Value Object design pattern?(Select two)
It reduces the network traffic. (Google)
It improves the efficiency of object operations.
It reduces the coupling between the data access module and the database.
It improves the response time for data access. (Google)
Which one of the following must be done before authorization takes place?
Data encryption
Data compression
Data validation
User authentication
How can you make sure that none of the sessions associated with a web application will ever be
expunged by the servlet container?
session.setMaxInactiveInterval(–1);
Set the session timeout in the deployment descriptor to 0 or –1.
Set the session timeout in the deployment descriptor to –1.
Set the session timeout in the deployment descriptor to 65535.
What are the benefits of using the Data Access Object pattern? (Select two)
It allows the clients to access the data source through EJBs.
It increases the performance of data–accessing routines.
The type of the actual data source can be specified at deployment time.
The data clients are independent of the data source vendor API.
We can use the directive < %@ page buffer="8kb" % > to specify the size of the buffer when returning
EVAL_BODY_BUFFERED from doStartTag().
Is the above statement true or false?
TRUE
FALSE
You are given a tag library that has a tag named getMenu, which requires an attribute, subject. This
attribute can take a dynamic value.
Which of the following are correct uses of this tag?
< mylib:getMenu > < jsp:param subject="finance"/ > < /mylib:getMenu >< mylib:getMenu / >
< % String subject="HR";% >
< mylib:getMenu subject=" < %=subject% > "/ >
< tring subject="HR";
< mylib:getMenu subject=" < lubject "/ >
The users of your web application do not accept cookies. Which of the following statements are
correct?
You cannot maintain client state.
You cannot use URL rewriting.
URLs displayed by static HTML pages may not work properly.
You cannot set session timeout explicitly.
Which design pattern allows you to decouple the business logic, data representation, and data
presentation?
Value Object
Business Delegate
Bimodal Data Access
Model–View–Controller
Which of the following elements are required for a valid < taglib> element inweb.xml? (Select two)
uri
taglib–uri
taglib–location
location
The bean instance will be available in that.jsp, and the that.jsp page can print the values of the beans
properties using
The bean instance will be available in that.jsp and the that.jsp page can print the values of the bean's
properties using < jsp:getProperty /> only if that.jsp also contains a < jsp:useBean/> declaration
identical to the one in this.jsp and before using < jsp:getProperty />
The bean instance may or may not be available in that.jsp, depending on the threading model
implemented by that.jsp
The bean instance will not be available in that.jsp
Which of the following lines would initialize the out variable for sending a Microsoft Word file to
the browser?
OutputStream out = response.getWriter();
ServletOutputStream out = response.getServletOutputStream();
PrintWriter out = response.getOuputStream();
OutputStream out = response.getOuputStream();
If the doStartTag() method returns EVAL_BODY_INCLUDE one time and thedoAfterBody() method
returns EVAL_BODY_AGAIN five times, how many times will the setBodyContent() method be called?
One
Zero
Two
Five
Which of the following methods will be invoked on a session attribute that implements appropriate
interfaces when the session is invalidated?
valueUnbound of HttpSessionBindingListener
attributeRemoved of HttpSessionAttributeListener
sessionDestroyed of HttpSessionListener
sessionWillPassivate of HttpSessionActivationListener
Consider the following code contained in a file named this.jsp (the same asabove, except the fourth
line):
< html > < body >
< jsp:useBean id="address" class="AddressBean" />
< jsp:setProperty name="address" property="*" />
< %@ include file="that.jsp" % >
< /body > < /html >
Which of the following is true about the AddressBean instance declared in the above code?
The bean instance will be available in that.jsp and the that.jsp page can print the values of the bean's
properties using < jsp:getProperty /> only if that.jsp
also contains a < jsp:useBean /> declaration identical to the one in this.jsp and before using <
jsp:getProperty />
The bean instance will not be available in that.jsp
The bean instance may or may not be available in that.jsp, depending on the threading model
implemented by that.jsp
The bean instance will be available in that.jsp, and the that.jsp page can print the values of the beans
properties using
Your web application, named Simpletax, depends on a third–party JAR file named taxpackage.jar.
Where would you keep this file?
simpletax/WEB–INF
simpletax/WEB–INF/classes
simpletax/WEB–INF/jars
simpletax/WEB–INF/lib
Consider the following < taglib > element, which appears in a deploymentdescriptor of a web
application:
< taglib >
< taglib–uri > /accounting < /taglib–uri >
< taglib–location > /WEB–INF/tlds/SmartAccount.tld < /taglib–location>
< taglib >
Which of the following correctly specifies the use of the above tag library in a JSP page?
< %@ taglib library="/accounting" prefix="acc"% >
< %@ taglib uri="/accounting" prefix="acc"% >
< %@ taglib name="/accounting" prefix="acc"% >
< %@ taglib uri="/acc" prefix="/accounting"% >
A web application is located in a directory named Sales. Where should its deployment descriptor be
located?
WEB–INF/sales
sales/WEB–INF
sales/deployment
sales/WEB
Which method is required for using the URL rewriting mechanism for implementing session
support?
HttpServletResponse.rewriteURL()
HttpServletRequest.rewriteURL()
HttpServletRequest.encodeURL()
HttpServletResponse.encodeURL()
Which of the following elements can you use to import a tag library in a JSP document?
< jsp:root >
< jsp:taglib >
< jsp:directive.taglib >
< jsp:taglib.directive >
Which of the following method calls will ensure that a session will never be expunged by the servlet
container?
session.setTimeout(Integer.MAX_VALUE);
session.setTimeout(Integer.MIN_VALUE);
session.setTimeout(–1);
None of the answer
Which method in the HttpServlet class services the HTTP POST request?
servicePost(HttpServletRequest, HttpServletResponse)
doPOST(ServletRequest, ServletResponse)
doPost(HttpServletRequest, HttpServletResponse)
doPost(ServletRequest, ServletResponse)
You are given a tag library that has a tag named printReport. This tag may accept an attribute,
department, which cannot take a dynamic value.
Which of the following are correct uses of this tag? (Select two)
< mylib:printReport/ >
< mylib:printReport attribute="department" attribute–value="finance"/ >
< mylib:printReport department="finance"/ >
< mylib:printReport attribute="department" value="finance"/ >