Submitted by heartin on Sat, 08/22/2015 - 22:49
Given an HttpServletRequest request and an httpServletResponse response:
HttpSession session = null;
/ / insert code here
if (session = = null) {
/ / do something if session does not exist
} else {
/ / do something if session exists
}
Which of the code below is more appropriate to be inserted instead of the line that contains '/ / insert code here' ?
A. session = response.getSession ();
B. session = request.getSession ();
C. session = request.getSession (true);
D. session = request.getSession (false);
E. session = request.getSession (“jsessionid”);
Submitted by heartin on Sat, 08/22/2015 - 22:38
How can you ensure that data is updated in a thread safe manner without using singieThreadModel?
Select 2
A. Store the data in a local variable.
B. Store the data in an instance variable.
C. Store the data in the Httpsession object.
D. Store the data in the sarvletContext object.
E. Store the data in the ServletRequest object.
Submitted by heartin on Sat, 08/22/2015 - 22:31
Which annotation enables a servlet to efficiently process requests of typo multipart/form-data that
involve large files being uploaded by the client?
A. @AcceptMultipart
B. @MultiPartConfig
C. @MultiPartFormData
D. @WebServlet (multipart = true
Submitted by heartin on Sat, 08/22/2015 - 22:25
Given an HttpServletRequest request and HttpResponse response, which sets a cookie “username” with the value “john” in a servlet?
A. request.addCookie("username", "john")
B. request.setCookie("username", "john")
C. response.addCookie("username", "john")
D. request.addHeader(new Cookie("username", "john"))
E. request.addCookie(new Cookie("username", "john"))
F. response.addCookie(new Cookie("username", "john"))
G. response.addHeader(new Cookie("username", "john"))
Submitted by heartin on Sat, 08/22/2015 - 11:59
What will the following code print when run?
public class TestClass {
public void switchString(String input){
switch(input){
case "a" : System.out.println( "apple" );
case "b" : System.out.println( "banana" );
break;
case "B" : System.out.println( "Banana" );
default : System.out.println( "none" );
}
}
public static void main(String[] args) throws Exception {
TestClass tc = new TestClass();
tc.switchString("B");
}
}
Select 1 option
A. banana
Banana
B. Banana
none
C. Banana
D. banana
E. The code will not compile.
Pages