This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Servlets and the fly likes Servlets JSP and Design FAQS Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Servlets
Reply locked New topic
Author

Servlets JSP and Design FAQS

sachin bellare
Greenhorn

Joined: Feb 13, 2004
Posts: 4
Which statement will insert static text from the tip.jsp file into a JSP page?

Choose One
<% include file='tip.jsp' %>
<%! include file='tip.jsp' %>
<%@ include file='tip.jsp' %> -------
<%= include file='tip.jsp' %>

In which class are the methods sendError and setStatus used to cause an HTTP error to be returned?

Choose One
HttpSessionEvent
HttpServletResponse ------
HttpSessionBindingEvent
HttpServletRequestWrapper
Assuming that the Servlet Container has just called the destroy() method of a servlet instance, which of the following statements are correct?

Choose One Or More
Any resources that this servlet might hold have been released. -----------
The servlet container time out has exceeded for this servlet instance.
The init() method has been called on this instance.
None of the requests can EVER be serviced by this instance.
All threads created by this servlet are done.

You want to write Servlet classes for a new web protocol of yours that you have developed.
What class would you extend your servlets from?

Choose One
HttpServlet
GenericServlet -------
Servlet
AbstractServlet

Assuming that a web application is marked as distributed, which of the following statements are correct?
Select 2 correct options.

Choose One Or More
All requests that belong to a session are handled by one JVM at a time.
HttpSession may not be migrated across the JVMs.
HttpSession may be migrated across the JVMs. ----
If an HttpSession is migrated, Java's Serialization mechanism is used to do so.
The attributes of a session can never be aware of any migration of the session.

Which of the following options can help you redirect an HTTP request to another URL?
Assume that request, response and urlString refer to objects of appropriate classes.

Choose One
calling forward(request, response) on a ServletContext object
calling forward(request, response) on a RequestDispatcher object ----
calling forward(urlString) on a RequestDispatcher object
calling redirect(urlString) on a Request object
calling redirect(request, response) on a RequestDispatcher object

which of the following J2EE design paterns can be used to efficiently transfer remote, fine-grained data by sending a coarse-grained view of the data?

Choose One
Fast-Lane Reader
Value Object ---
Session Facade
Data Access Object
Use ServiceLocator/EJBHomeFactory Pattern to reduce expensive JNDI lookup process.
Use SessionFacade Pattern to avoid direct client access to Entity beans thus reducing network calls.
Use MessageFacade/ServiceActivator Pattern to avoid large method execution process.
Use ValueObject Pattern to avoid fine grained method calls over network.
Use ValueObjectFactory/ValueObjectAssembler Pattern to avoid multiple network calls for a single client request.
Use ValueListHandler Pattern to avoid using Entity beans and send data iteratively to the client.
Use CompositeEntity Pattern to avoid inter Entity bean overhead.


The loadiing time for included resource is the same for both JSP directive (@include file="filename") and JSP action (jsp:include page="pageURL" flush="true").

Choose One
True
False

The getCallerPrincipal method of the EJBContext interface can be used to find which of the following?

Choose One
The identity of the calling client
Whether the client accessing the bean is a member of any defined role
The access level of the caller
Whether the caller identity is secure or not

In JMS Point-to-Point messaging, which of the following is NOT true?

Choose One
Each message has only one consumer
The receiver can fetch the message only if it was running when the client sent the message.
The receiver acknowledges the successful processing of a message.
All of the above

You have a set of data that represents the history of the prices of certain stocks. You are required to present this information in different ways such as graphs or simple text etc. to end users.
Which design pattern would be most suitable to handle such requirement?

Choose One
Data Stream
Data Feed
Model View Controller
Data Client Controller
Client View Server

When is MVC design pattern very useful?

Choose One Or More
when the presentation keeps changing depending on user feedback.
when the database vendor changes dues to pricing.
when the data has to be presented to different kind of users.
when the data representation keeps changing due to defective data modelling.
when the EJBs have a lot of attributes.


Which of the following statements are correct?
Select 2 correct options.

Choose One Or More
Using Value Object pattern ensures that the data is not stale.
It is good to make the value object immutable.
Applying Value Object pattern on EJBs helps in reducing load on enterprise beans.
MVC does not help much if the presentation of the data keeps changing frequently.

You are building the server side of an application and you are finalizing the interfaces that you'll provide to the client side. But you have not yet decided whether the business rules will be fully implemented as stored procedures or in the java code. Which design pattern you should use to mitigate this concern?

Choose One
Model View Controller
Business Delegate
Data Access Object
Facade
Value Object

Which pattern enables improved network traffic and response time. Fewer remote calls are made and less data is passed back and forth

Choose One
Value Objects
Data Access Objects
Facade
Business Delegate
MVC

Which of the following elements of web.xml defines a mapping between a servlet and a URL pattern?

Choose One
mapping
servlet-url
servlet-mapping
url_pattern
url_mapping

Assuming that the Servlet Container has just called the destroy() method of a servlet instance, which of the following statements are correct?

Choose One Or More
Any resources that this servlet might hold have been released.
The servlet container time out has exceeded for this servlet instance.
The init() method has been called on this instance.
None of the requests can EVER be serviced by this instance.
All threads created by this servlet are done.

Assuming that the servlet container is distributed across multiple JVMs, which of the following statements are correct?
Select 2 correct options.

Choose One Or More
A separate instance of a non-default servlet context will be available on each of the JVMs.
A separate instance of all servlet context will be avaible on each of the JVMs
The default servlet context will be present only on one of the JVMs.
There is only one instance of servlet contexts across all the JVMs.
None of the above.
Identify the techniques that can be used to implement 'sessions' if the client browser does not support cookies.

Choose One Or More
Using Http headers.
Using https protocol.
Hidden form fields.
URL rewriting
It cannot be done without cookie support.

In which of the following situations will a session be definitely invalidated?

Choose One Or More
The container is shutdown and brought up again.
No request comes from the client for more than "session timeout" period.
A servlet explicitly calls invalidate() on a session object.
If the session time out is set to 0 using setMaxInactiveInterval() method, the session will never be invalidated automatically.

Which of the following statements correctly store an object associated with a name at a place where all the servlets/JSPs of the same webapp participating in a session can use it?

Choose One Or More
request.setAttribute(name, value);
response.setAttribute(name, value);

Assuming that a web application is marked as distributed, which of the following statements are correct?
Select 2 correct options.

Choose One Or More
All requests that belong to a session are handled by one JVM at a time.
HttpSession may not be migrated across the JVMs.
HttpSession may be migrated across the JVMs.
If an HttpSession is migrated, Java's Serialization mechanism is used to do so.
The attributes of a session can never be aware of any migration of the session.



You want to do some calculations whenever an object of a particular class is added to the session. What would you do to accomplish this?

Choose One
Configure a HttpSessionAttributesListener in deployment descriptor
Make the class of the object implement HttpSessionBindingListener
Make the class of the object implement HttpSessionListener
Configure a HttpSessionActivationListener in deployment descriptor
Only way is to configure a HttpSessionAttributesListener in deployment descriptor
Does Java allow operator overloading for custom classes?

Choose One
Yes
No


Which of the following J2EE design paterns can be used to efficiently transfer remote, fine-grained data by sending a coarse-grained view of the data?

Choose One
Fast-Lane Reader
Value Object
Session Facade
Data Access Object

The loadiing time for included resource is the same for both JSP directive (@include file="filename") and JSP action (jsp:include page="pageURL" flush="true").

Choose One
True
False


In JMS Point-to-Point messaging, which of the following is NOT true?

Choose One
Each message has only one consumer
The receiver can fetch the message only if it was running when the client sent the message.
The receiver acknowledges the successful processing of a message.
All of the above


What are the benefits of using Data Access Object pattern?

Choose One Or More
The type of the actual data source can be specified at deployment time
The data clients are independent of the data source vendor API
It increases the performace of data accessing routines
It allows the clients to access the data source through EJBs
It allows resource locking in an efficient way


request.getSession().setAttribute(name, value);
servlet.getServletContext().setAttribute(name, value);
request.setParameter(name, value
Assuming that the servlet container is distributed across multiple JVMs, which of the following statements are correct?
Select 2 correct options.

Choose One Or More
A separate instance of a non-default servlet context will be available on each of the JVMs. ----
A separate instance of all servlet context will be avaible on each of the JVMs ---
The default servlet context will be present only on one of the JVMs.
There is only one instance of servlet contexts across all the JVMs.
None of the above.

Which of the following statements correctly store an object associated with a name at a place where all the servlets/JSPs of the same webapp participating in a session can use it?

Choose One Or More
request.setAttribute(name, value);
response.setAttribute(name, value);
request.getSession().setAttribute(name, value); ----
servlet.getServletContext().setAttribute(name, value);
request.setParameter(name, value)


You want to do some calculations whenever an object of a particular class is added to the session. What would you do to accomplish this?

Choose One
Configure a HttpSessionAttributesListener in deployment descriptor ---
Make the class of the object implement HttpSessionBindingListener --
Make the class of the object implement HttpSessionListener
Configure a HttpSessionActivationListener in deployment descriptor
Only way is to configure a HttpSessionAttributesListener in deployment descriptor
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
So this is either a homework assignment or you are offering the new "sachin bellare servlet certification". In any case, how about taking one question that you don't understand and asking it in a different thread. I am closing this one.


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlets JSP and Design FAQS