SCWCD-2 04/14/2008
 

Which of the following can be used to configure the JSP container to ignore EL expressions?
A <%@ page isELIgnored="true" %>
B <%@ page isELIgnored="false" %>
C <%@ import isELIgnored="false" %>
D None of the above.

Answer
D
Configuring the <el-ignored> tag inside the DD is the only way to ignore EL expressions. There was a isELIgnored attribute for page directive in the 2.0 draft version. But it is removed from the final version.

Which method is used to retrieve objects from session?
A getAttribute method of javax.servlet.ServletSession.
B getAtrribute method of javax.servlet.HttpSession
C getAttribute method of javax.servlet.http.Session
D getAttribute method of javax.servlet.http.HttpSession
E getAttribute method of javax.servlet.HttpSession

Answer
D
All other answers are invalid because no such classes present.

Which among the following will compile ?
A <% int x=10 %>
B <%= "hello how are you" %>
C <%= "hello" ;% >
D <%! int x=10 %>

Answer
B
Option B is the correct choice. A is in correct because there is no semi colon present. The same rule applies to option D also. Option C is in correct because of semi colon

Which of the following is the proper way to include java.util package in your jsp page?
A <%@page:import package="java.util">
B <%@ page import = "java.util.*" %>
C <%= import java.util.*; %>
D <%@ page import="java.util.*" %>

Answer
D
Answer A is incorrect because, there is no such thing called <%@page import package. Answer B is incorrect because , we cannot have space between page and = sign. Answer c is correct, because it is a JSP expression.

Consider the following code snippet of servlet code:
public void doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = response.getWriter();
String value = getValue ();
if (value == null)
response.sendError (HttpServletResponse.SC_NOT_FOUND, "Failed");
response.sendRedirect ("test.jsp");
}
If the getValue () method returns null , which of the following statements are true?
A The code will work without any errors or exceptions
B An IllegalStateException will be thrown
C An IOException will be thrown
D A NullPointerException will be thrown

Answer
B
Since the response is already committed by calling the sendError() , we cannot redirect it once again

To send binary output to response, which method of HttpServletResponse is used to get the Writer/ Stream object ?
A getStream
B getWriter
C getBinaryOutputStream
D getOutputStream
E getBinaryStream

Answer

D
The getOutputStream is used for sending binary data. The getWriter is used for sending character data only

<%@ page language ="java" session="false" isErrorPage="false" %> which of the following JSP implicit object will not be available to the JSP page ? Select two
A session
B request
C application
D exception

Answer
A and D
Since we are disabling the session by using session="false", session will not be available. And since this page is not an error page , so exception also will not be available.

What will be the output of the following JSP code?
<html>
<body>
<%! int a = 20; %> <% int a = 10; %> <%! int b = 30; %> Now b = <%= b * a %>
</body>
</html>

A Now b = 300
B Now b = 600
C The code will not compile
D Now b = 30
E Now b = 0

Answer
A
In the first declaration <%! int a = 20; %>, the variable "a" will be declared as an instance variable. In the second declaration <% int a = 10; %>, the variable "a" will be declared as a local variable inside the service method. And at the time of multiplication it will use the local variable.

What is the default scope for <jsp:useBean>
A application
B session
C page
D request

Answer
C
The default scope attribute for useBean is page

In a JSP custom tag , which method would you use to access JSP implicit variable that references application scope ?
A PageContext.getOut()
B jspFactory.getPageContext()
C TagSupport.getValue(String)
D pageContext.getServletContext()

Answer
D

 


Comments

Tamilselvan

Fri, 13 Jun 2008 23:55:08

 



Leave a Reply

    SCWCD Sets


    Archives

    May 2008
    April 2008