These JSP and Servlets multiple-choice questions and their answers will help you strengthen your grip on the subject of JSP and Servlets. You can prepare for an upcoming exam or job interview with these 100+ JSP and Servlets MCQs.
So scroll down and start answering.
A. If myVar is an HttpSession, s is guaranteed to have the value “myVal”
B. The value of s cannot be guaranteed
C. If myVar is a ServletContext, compilation will fail
D. If myVar is an HttpSession, compilation will fail
A. For each request that causes a new session to be created
B. For each request that causes a new thread to be created
C. For each request
D. Only once in the life time
A. jsp:useBean
B. jsp:setProperty
C. jsp:setSession
D. jsp:getProperty
A. Java Servlet Pages
B. Justified Secure Pages
C. Java Server Pages
D. Java Server Program
A. < expression />
B. <=% expression %>
C. <%= expression %>
D. <% expression %>
A. POJO
B. HTML
C. Applet
D. Servlet
A. a taglib
B. a http request
C. a sql update
D. class
A. <@ java code @>
B. <% java code %>
C. <$ java code $>
D. <# java code #>
A. browser.println();
B. page.println();
C. out.println();
D. html.println();
A. WildCat
B. Tomcat
C. MySQL
D. FaceBook
A. PHP
B. C#
C. javascript
D. Java
A. <%% Page import="java.io.*" %>
B. <%@ page import="java.io.*" %>
C. <%-- Page import="java.io.*" %>
D. <%&& Page import="java.io.*" %>
A. database
B. the server
C. C#
D. smartphone
A. try() catch()
B. catch() { } try { }
C. try [] catch() []
D. try { } catch () { }
A. <%@ page import="java.text.*" %>
B. <%= Page import="java.text.*" %>
C. <%& Page import="java.text.*" %>
D. <%() Page import="java.text.*" %>
A. if {} ( )
B. if [] { }
C. if <> {}
D. if () { }
A. VB.Net
B. Java
C. Python
D. C#
A. Date() myDate[];
B. Declare myDate = new Date();
C. myDate = Date();
D. Date myDate = new Date();
A. Kornshell script
B. HTTP
C. port 1433
D. a sql request
A. if(x ==+ 1) { }
B. if(x == 1) { }
C. if(x += 1) { }
D. if(x = 1) { }
A. JSP.xml
B. Client.xml
C. HTML.aspx
D. web.xml
A. <%-- comment --%>
B. <// comment //>
C. < comment />
D. <%= comment =>
A. () comment
B. // comment
C. ?/ comment
D. # comment
A. var_str = String("this");
B. var_str = "this";
C. String var_str = "this";
D. Declare var_str = "this";
A. <%= taglib prefix="c" uri="http..." %>
B. <%@ taglib prefix="c" uri="http..." %>
C. <%-- taglib prefix="c" uri="http..." %>
D. <%() taglib prefix="c" uri="http..." %>
A. the client
B. a mobile phone
C. the server
D. in the browser
A. Javascript holds all the data.
B. All data is stored in the database
C. Once a connection is open then closed, the web server doesn't recognize the request or any past requests.
D. Nothing. Its not an important concept.
A. web.xml
B. spring.xml
C. server.xml
D. config.xml
A. ServletConfig
B. Both ServletRequest & ServletResponse
C. ServletResponse
D. ServletRequest
A. POST
B. HIDDEN
C. GET
D. HEAD
A. <%@ page %>
B. <%^ Page %>
C. <%= Page %>
D. <%# Page %>
A. <sql:update> </sql:update/>
B. <sql:update> </sql:update>
C. <sql|update> </sql=update>
D. <sql:update> <//sql:update>
A. Cookie cookie = new Cookie("key","value")
B. JSP cookie = new JSPCookie("key","value")
C. Create new cookie()
D. There is no way to call a cookie
A. a compatible web server container
B. a compatible web server with a servlet container
C. a compatible web server without a servlet container
A. session and Cookies
B. Cookies
C. HTML
D. ASP
E. session
A. server.xml
B. hibernate.cfg.xml
C. context.xml
D. web.xml
A. By default it is a GET request
B. By default it is a Post request
A. checks to see if HTML 5 is being used
B. see if the page needs to be compiled
C. checks to see if the browser is Safari or IE
D. checks to see if the cookies are enabled
A. Page Scope
B. Session Scope
C. Application Scope
D. Request Scope
A. Cookies, HTML, URL rewrite
B. Web server, HTML, ASP
C. Cookies, hidden fields, URL rewrite.
D. HTML, Database, javascript
A. page_load()
B. jspDestroy()
C. jspInit()
A. ServletConfig getServletConfig()
B. public void init() throws ServletException
C. public void destroy()
D. public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException{
A. highlighted
B. not included
C. promoted
D. executed first
A. jsp:forward
B. jsp:useBean
C. jsp:param
D. jsp:include
A. config
B. page
C. session
D. request
A. tag-location
B. taglib-uri
C. taglib-location
D. Both taglib-uri and taglib-location
A. tries to find an object, creates it if it does not exist
B. none of these options are correct
C. does not do anything
D. converts HTML to a class
A. jspRelease()
B. jspInit()
C. jspDestroy()
D. jspService()
A. <%@import java.util.* %>
B. <%@ page import="java.util.*"%>
C. <%import="java.util.*"@%>
D. <%@ page java="java.util.*"@%>
A. public string myFunc(String name) { return name;}
B. public myFunc(String name) { return name;}
C. None of these
D. public string myFunc(String name) { }