Quiz
Questões - The Servlet's Environment
Create a free account to finish this quiz
Save your progress and see your final score.
Already have an account? Sign in
Questions in this quiz (20)
1Why do the client and server need a unique session id for conversations?
- ABecause HTTP is a stateful protocol.
- BBecause HTTP is a stateless protocol
- CFTP is a stateful protocol
- DNone of the above
2What is the method in the HttpSession interface to know if a session is new or not?
- AgetSession();
- BisSessionNew();
- CsessionNew();
- DisNew();
3What is the method in the HttpServletRequest interface to know if a session exists or not?
- AgetSession(boolean);
- BsessionExists();
- CgetSession();
- DdoesSessionExists()
4URL encoding is done by:
- AHttpServletRequest
- BServletContext
- CServletRequest
- DHttpServletResponse
5What type of session tracking is used for static pages?
- ACookies
- BURL rewriting
- CBoth Cookies and URL rewriting
- DNone of the mentioned
6What is wrong with the following line of code?
String sessid = request.getParameter("jsessionid");- A"jsessionid" is not a parameter that can be passed.
- BNothing is wrong with this code.
- CThe getParameter should take an object as its parameter.
- DThe code should be re-written as:
String sessid = request.getAttribute("jsessionid");
7In the setMaxInactiveInterval() method in the HttpSession interface, the parameter 'interval' specified below is represented in:
void setMaxInactiveInterval(int interval);- AHours
- BMinutes
- CSeconds
- DMilliseconds
8When you set the session timeout in the deployment descriptor as in the following example, the timeouts are specified in...
- AHours
- BMinutes
- CSeconds
- DMilliseconds
9Consider the code:
What will be the output of the following code?
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.*;
import javax.servlet.http.*;
public class SampleServlet extends HttpServlet{
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException{
response.setContentType("text/html");
PrintWriter out=response.getWriter();
HttpSession sess1=request.getSession();
sess1.invalidate();
if(sess1.isNew()){
System.out.println("A new session has been created");
}else{
System.out.println("The session cannot be created");
}
}
}- AThe message "A new session has been created" is output.
- BThe message "The session cannot be created" is output.
- CCompile error.
- DIllegalStateException
10Consider the following code:
Cookie c = new Cookie("user",name);
c.setMaxAge(-10);
What happens when the above code is implemented?- AThe Cookie lives for 10 minutes.
- BThe Cookie will be erased once the web browser quits.
- CThe Cookie lives for 10 seconds.
- DThe Cookie is deleted.
11In a distributed environment, there is ________ HttpSession object for a given session ID per web application inspite of the number of VMs it is distributed across.
- AOne
- BTwo
- CDepends on the number of VMs it is present on
- DNone of the above
12What are the methods in the HttpSessionActivationListener interface?
- AsessionWillActivate(HttpSessionEvent e) and sessionDidPassivate(HttpSessionEvent e)
- BsessionDidActivate(HttpSessionEvent e) and sessionWillPassivate(HttpSessionEvent e)
- CsessionActivate(HttpSessionEvent e) and sessionPassivate(HttpSessionEvent e)
- DsessionWillActivated(HttpSessionEvent e) and sessionDidPassivated(HttpSessionEvent e)
13Consider this code:
public class MySessionAttributeListener implements HttpSessionAttributeListener{
public void attributeAdded(HttpSessionAttributeEvent e){
System.out.println("Attribute added");
}
public void attributeRemoved(HttpSessionAttributeEvent e){
System.out.println("Attribute removed");
}
public void attributeReplaced(HttpSessionAttributeEvent e){
}
}- ACode is perfectely fine.
- BThe HttpSessionAttributeListener has one more method that has to be implemented.
- CThe event has to be HttpSessionBindingEvent.
- DThe "attributeReplaced()" method should not be present.
14Consider the listener class:
public class MySessionBindingListener implements HttpSessionBindingListener{
public void valueBound(HttpSessionBindingEvent e){
}
public void valueUnbound(HttpSessionBindingEvent e){
}
}
And the corresponding Deployment Descriptor:
< web-app >
-----------------
----------
< listener >
< listener-class> MySessionBindingListener < / listener-class >
< / listener >
What is wrong with this code?- ANothing is wrong with this code.
- BThe HttpSessionBindingListener has to implement one more method.
- CThe listener class is configured wrongly.
- DThe HttpSessionBindingListener need not be configured in the Deployment Descriptor.
15What is the HttpSessionActivationListener used for?
- ATo know how many concurrent users are there.
- BTo know when session attributes are added, removed or replaced in a session.
- CTo let attributes know when they are moved from one VM to another as part of a session.
- DNone of the options.
16List the four concepts in servlet security.
Select four options.- AAuthentication
- BEavesdropping
- CAuthorization
- DConfidentiality
- EFoilling
- FData integrity
17In a web application, it is better to handle security declaratively or programmatically?
- ADeclaratively
- BProgrammatically
18Once the user makes a request for a constrained resource, the user is asked to enter the name and password
- AAuthentication
- BAutorization
- CConfidentiality
- DData integrity
19The Container checks to see if the user is in the required role to access the resource.
This is an example of:- AAuthentication.
- BAuthorization.
- CConfidentiality.
- DData integrity.
20How many types of authentication are there?
- A2
- B3
- C4
- D5
Information
- Description
- Concursos Públicos Desenvolvimento de Software (OCEJWCD 6 ONLINE COURSE) Quiz on Questões - The Servlet's Environment, created by Luis Felipe Guariento on 19/02/2018.
- Author
- Luis Felipe Guariento
- Language
- Português
- Views
- 0
- Tags
- Rating
- No ratings yet Rate this quiz