Servlets Multiple Choice Question


Hello friends in this post we are going to discuss about Servlets MCQ with Answer | Servlets Objective type questions with answer | Servlets Multiple choice question | Servlets Question Answer PDF | Servlet Wipro MySkillz Trend NXT Dumps

1) Which JSP implicit object is an instance of the java.lang.Object class?

Ans : page

2)What object that provides one point access to page, request, response, session, out, exception, config and application is

Ans: PageContext

3) <%@ include file=”filename.inc” %>, includes the content of the specified file during the translation phase the include action,

Ans – <jsp:include page=”pagename.jsp” flush=”true” />, includes the response generated by executing the specified page (a JSP page or a servlet) during the request processing phase.

4) Which method is used to send huge amount of binary data

Ans: POST

5)How to import the packages java.sql.*,java.util.* in JSP

Ans: <%@ page import=”java.sql.*,java.util.*”  %>

6)Initialization phase of Jsp lifecycle which method will be called

Ans: jspInit

If you are looking for more Dumps for MYSKILLZ Visit Here

7) Which declaration is true?

Ans: <%! int i; %> <%=i>

8) How to add cookie Username, Joe is

Ans: response.addCookie(new Cookie(Username,”Joe”));

9) Which method is used to get the value of a form parameter?

Ans:  getParameter()

10) This header lets you request that the browser ask the user to save the response to disk in a file of the given name.

Ans: Content-Disposition

11) Java get referer URI?

Ans: referer

12) The init method is designed to be called only once. It is called when the servlet is first created,and not called again for each user request

13)ServletConfig is used to get the initialization parameter for a servlet

14) Which action tag is used to locate or instantiate a bean class. —- jsp:useBean

15).jar files contains all classes located in which folder —– /WEB-INF/lib

16) The forward () method works at server side.

The sendRedirect() method works at client side.

17) URL using GET method : /test/demo_form.asp?name1=value1&name2=value2

18)<@include file=”filename.jsp?name=”JOE”>

OUTPUT:

500 internal server error

19) The request-header field can be used to indicate what character sets are acceptable for the response is Accept-Charset

20) The header specifies the time at which the content should be considered out-of-date and thus no longer be cached is Expires

21) Which method ensures that the session will never be expunged by the container ? session.setMaxInactiveInterval(-1);

22) Which is not a JSP Implicit Objects?

a)session b)HttpSession c)config d)request

Ans:HttpSession

23)<jsp:getProperty name=”bean’s id” property=”property name”/>

24) How to specify the superclass in jsp <%@page extends = “package.classname”%>

25) How to continue the session when browser doesn’t support to the cookies –  hidden parameters

26) How to add an attribute type = “accessory” —

<jsp:attribute name=”type”>

 Accessory

</jsp:attribute>

27) How will include the property name in the jsp — <jsp:getProperty>

28)syntex for error page —

<error-page>

    <exception-type>java.lang.Throwable</exception-type >

    <location>/ErrorHandler</location>

</error-page>

29) what is deployment descriptor

web.xml

30) Servlet container calls init() …

ans : only once for the lifetime of servlet instance

31) Loading servlets in sequence order

ans : specifying loadonstartup in web.xml

32) if the parameter appears more than once in jsp ,method to retrive those multiple values

ans: getParameterValues()

33)url rewriting is used when

ans: browser doesnt support cookies

34) Which method is called after the jsp is invoked and initialised

ans: _jspservice()

35) Which header is used by clients to identify themselves when accessing password-protected Web Pages?

ans :Authorization

36) Which of the below specifies a superclass of the jsp

ans: extends

37) Which is used to discard the content in main.jsp and include the content of date.jsp

jsp:forward

38) To specify a attribute type =”Accessory” in jsp , which is of the below is correct

<jsp:attribute name=”type”>


 Accessory

</jsp:attribute>

39) Which header is used in conjuction with 503 error to ask the client to try again after sometime

retry-after

40) To retrive the value of a form parameter  

ans : request.getParameter()

41) Third party jar files located in which folder

ans: /WEB-INF/lib

42) By setting public int getMaxAge() equals to -1 indicating the cookie will persist until browser shutdown.

42) In which directory servlets are kept

A) WEB-INF b) WEB-INF/classes c)WEB-INF/servlets d)WEB-INF/lib

43) What is the legal jsp syntax to print the value of i

a) <% int i=1$%> <%=i;%>

b) <% int i=1;%> <%=i%>

c) <% int i=1; I;%>

d) <% int i=1%> <%=i%>

44) What do you mean by lazy loading of servlet?

————————————————————————————-

Have a look at below also:

JSP Implicit Objects:-

1) The JSP implicit page object is an instance of the java.lang.Object class.

2) Request implicit object – javax.servlet.http.HttpServletRequest interface

3) Response implicit object – javax.servlet.http.HttpServletResponse interface

4) Out implicit object – javax.servlet.jsp.JspWriter class

5) Session implicit object – javax.servlet.http.HttpSession interface

6) Application implicit object – javax.servlet.ServletContext interface

7) Exception implicit object – java.lang.Throwable class

8) config implicit object – javax.servlet.ServletConfig interface

9) Page implicit object –  java.lang.Object class

10) pageContext implicit object – javax.servlet.jsp.PageContext abstract class

JSP Actions:-

1) jsp:include Includes a file at the time the page is requested

2) jsp:useBean Finds or instantiates a JavaBean

3) jsp:setProperty Sets the property of a JavaBean

4) jsp:getProperty Inserts the property of a JavaBean into the output

5) jsp:forward Forwards the requester to a new page

6) jsp:plugin Generates browser-specific code that makes an OBJECT or EMBED tag for the Java plugin

7) jsp:element Defines XML elements dynamically.

8) jsp:attribute Defines dynamically defined XML element’s attribute.

9) jsp:body Defines dynamically defined XML element’s body.

10) jsp:text Use to write template text in JSP pages and documents.

Tags:-

1) The Scriptlet – <% code fragment %>

2) JSP Declarations – <%! declaration; [ declaration; ]+ … %> (<%! int i = 0; %>)

3) JSP Comments – <%– This is JSP comment –%>

4) A JSP comment. Ignored by the JSP engine. – <%– comment –%>

5) An HTML comment. Ignored by the browser. – <!– comment –>  

6) JSP Directives

<%@ page … %> Defines page-dependent attributes, such as scripting language, error page, and buffering requirements.

<%@ include … %> Includes a file during the translation phase.

<%@ taglib … %> Declares a tag library, containing custom actions, used in the page

If you are looking for more Dumps for MYSKILLZ Visit Here


Leave a Reply

Your email address will not be published. Required fields are marked *