1. What is JSP?
a. Java Software Package
b. Java Static Page
c. Java Server Page
d. Java Source Page
Answer: c
2. What is the extension of JSP file?
a. .jspf
b. .jsp
c. .java
d. .jsf
Answer: b
3. Which method is used to destroy a JSP page?
a. detach()
b. destroy()
c. close()
d. unload()
Answer: b
4. What is the role of JSP scripting elements?
a. To provide dynamic content
b. To provide static content
c. To provide database connection
d. To provide user input
Answer: a
5. What is the difference between JSP and Servlet?
a. JSP generates HTML while Servlet doesn’t
b. Servlet generates HTML while JSP doesn’t
c. Both generate HTML
d. Neither generates HTML
Answer: b
6. Which interface is implemented by JSP page?
a. ServletConfig
b. HttpRequest
c. HttpResponse
d. HttpSession
Answer: a
7. What is the full form of EL in JSP?
a. Expression Language
b. Element Language
c. Event Language
d. Exceptional Language
Answer: a
8. Which operator is used in EL for null checking?
a. !=
b. ==
c. %
d. ?
Answer: d
9. What is the purpose of JSP standard tag library?
a. To improve the performance of JSP
b. To provide JSP tags for common tasks
c. To provide database connection
d. To provide user input
Answer: b
10. What is the syntax to use JSTL in JSP?
a. <%@ taglib uri=”http://java.sun.com/jsp/jstl/core” prefix=”c” %>
b. <%@ jstl lib=”http://java.sun.com/jsp/jstl/core” prefix=”c” %>
c. <%@ taglib uri=”http://java.sun.com/jsp/jstl” prefix=”c” %>
d. <%@ jstl lib=”http://java.sun.com/jsp/jstl” prefix=”c” %>
Answer: a
11. What is the syntax to declare a variable in JSP?
a. <%! int a; %>
b. <% int a; %>
c. <%@ int a; %>
d. <%# int a; %>
Answer: a
12. What is the purpose of tag?
a. To include the contents of another JSP file
b. To include the contents of a servlet response
c. To include the contents of a text file
d. To include the contents of a Java file
Answer: a
13. What is the default scope of JSP variables?
a. request
b. session
c. application
d. page
Answer: d
14. What is the purpose of tag?
a. To forward the request to another JSP page
b. To forward the request to a servlet
c. To forward the request to a HTML file
d. To forward the request to a text file
Answer: a
15. What is the purpose of tag?
a. To declare a Java bean
b. To create a Java bean instance
c. To set the properties of a Java bean
d. All of the above
Answer: d
16. What is the syntax to use custom JSP tags?
a. <%@ taglib uri=”mytags” prefix=”m” %>
b. <%@ taglib lib=”mytags” prefix=”m” %>
c. <%@ jsp taglib uri=”mytags” prefix=”m” %>
d. <%@ jsp lib=”mytags” prefix=”m” %>
Answer: a
17. What is the role of tag?
a. To include a Java applet
b. To include a JavaScript
c. To include a style sheet
d. To include a Flash animation
Answer: a
18. What is the syntax to include a static resource in JSP?
a. <%@ include file=”static.html” %>
b. <%@ include page=”static.html” %>
c. <%@ include src=”static.html” %>
d. <%@ include url=”static.html” %>
Answer: a
19. What is the syntax to use conditional statement in JSP?
a. <% if(condition) { %> Content <% } %>
b. Content
c. Both a and b
d. None of the above
Answer: c
20. What is the syntax to use loop statement in JSP?
a. <% for(int i=0; i<10; i++) { %> Content <% } %>
b. Content
c. Both a and b
d. None of the above
Answer: c
21. What is the purpose of tag?
a. To include the output of a Java expression
b. To include the output of a JavaScript expression
c. To include the output of a style sheet
d. To include the output of a Flash animation
Answer: a
22. What is the syntax to set the status code in JSP?
a. <% response.setStatus(200); %>
b. <%@ page status=”200″ %>
c. <%! int status=200; %>
d. <%! response.setStatus(200); %>
Answer: a
23. What is the purpose of <%= %> in JSP?
a. To execute a Java code
b. To output the value of a Java expression
c. To include a Java file
d. To include a JavaScript file
Answer: b
24. What is the syntax to use try-catch block in JSP?
a. <% try { %> content <% } catch(Exception e) { %> content <% } %>
b. content
c. Both a and b
d. None of the above
Answer: a
25. What is the purpose of tag?
a. To create an HTML element
b. To create a JavaScript element
c. To create a style sheet element
d. To create a Flash element
Answer: a
26. What is the purpose of tag?
a. To set the parameter values of a request
b. To set the parameter values of a response
c. To set the parameter values of a session
d. To set the parameter values of a application
Answer: a
27. What is the purpose of tag?
a. To set the page encoding
b. To set the session timeout
c. To set the application context
d. To set the cache control
Answer: a
28. What is the purpose of tag?
a. To include the contents of a file at the translation time
b. To include the contents of a file at the runtime
c. To include the contents of a JSP page at the runtime
d. To include the contents of a servlet at the runtime
Answer: a
29. What is the purpose of tag?
a. To forward the control to another page
b. To forward the control to a servlet
c. To forward the control to a JavaScript
d. To forward the control to a style sheet
Answer: a
30. What is the syntax to use session object in JSP?
a. <% session.setAttribute(“name”, value); %>
b. <% session.getAttribute(“name”); %>
c. <% session.invalidate(); %>
d. All of the above
Answer: d
31. What is the syntax to use request object in JSP?
a. <% request.setAttribute(“name”, value); %>
b. <% request.getAttribute(“name”); %>
c. <% request.getQueryString(); %>
d. All of the above
Answer: d
32. What is the purpose of tag attribute class?
a. To specify the class of the bean
b. To specify the properties of the bean
c. To specify the scope of the bean
d. None of the above
Answer: a
33. What is the purpose of tag attribute id?
a. To specify the class of the bean
b. To specify the properties of the bean
c. To specify the scope of the bean
d. None of the above
Answer: c
34. What is the purpose of tag attribute flush?
a. To send the response to the client immediately
b. To wait until the end of the request to send the response
c. To compress the response before sending it
d. To encrypt the response before sending it
Answer: a
35. What is the purpose of tag attribute pageEncoding?
a. To specify the content type of the included file
b. To specify the character encoding of the included file
c. To specify the MIME type of the included file
d. To specify the HTTP status code of the included file
Answer: b
36. What is the purpose of tag attribute page?
a. To forward the control to another JSP page
b. To forward the control to a servlet
c. To forward the control to a HTML file
d. To forward the control to a Java file
Answer: a
37. What is the purpose of tag attribute file?
a. To specify the file to be included at the translation time
b. To specify the file to be included at the runtime
c. To specify the file to be included in the response
d. To specify the file to be included in the session
Answer: a
38. What is the purpose of tag attribute scope?
a. To specify the class of the bean
b. To specify the properties of the bean
c. To specify the scope of the bean
d. None of the above
Answer: c
39. What is the purpose of tag attribute contentType?
a. To specify the content type of the page
b. To specify the character encoding of the page
c. To specify the output format of the page
d. To specify the style sheet of the page
Answer: a
40. What is the purpose of tag?
a. To specify the parameter of a request
b. To specify the parameter of a response
c. To specify the parameter of a session
d. To specify the parameter of a application
Answer: a
41. What is the purpose of tag attribute redirect?
a. To forward the control to another page
b. To forward the control to a servlet
c. To redirect the control to another page
d. To redirect the control to a servlet
Answer: c
42. What is the purpose of tag attribute isErrorPage?
a. To specify that the page will handle exceptions
b. To specify that the page will handle errors
c. To specify that the page will handle requests
d. To specify that the page will handle responses
Answer: a
43. What is the purpose of tag attribute buffer?
a. To specify the size of the buffer
b. To specify the content type of the buffer
c. To specify the encoding of the buffer
d. To specify the cache control of the buffer
Answer: a
44. What is the purpose of tag attribute codebase?
a. To specify the location of the Java applet
b. To specify the browser type
c. To specify the browser version
d. To specify the MIME type of the applet
Answer: a
45. What is the purpose of tag attribute name?
a. To specify the name of the parameter
b. To specify the value of the parameter
c. To specify the scope of the parameter
d. To specify the content type of the parameter
Answer: a
46. What is the purpose of tag attribute language?
a. To specify the scripting language
b. To specify the markup language
c. To specify the encoding
d. To specify the MIME type
Answer: a
47. What is the syntax to forward the control to another servlet with parameter?
a. <%@ page import=”javax.servlet.http.” %> <% String url=”Servlet2″; %> <% RequestDispatcher rd=request.getRequestDispatcher(url); %> <% rd.forward(request,response); %> b. <%@ page import=”javax.servlet.http.” %>
<% String url=”Servlet2″; %>
<% response.sendRedirect(url+”?user=”+user+”&password=”+password); %>
c. <%@ page import=”javax.servlet.http.*” %>
<% String url=”Servlet2?user=”+user+”&password=”+password; %>
<% RequestDispatcher rd=request.getRequestDispatcher(url); %>
<% rd.forward(request,response); %>
d. None of the above
Answer: c
48. What is the syntax to include the contents of a JSP page in another JSP page?
a. <%@ include file=”page2.jsp” %>
b. <%@ page import=”page2.jsp” %>
c. <%@ include src=”page2.jsp” %>
d. <%@ include url=”page2.jsp” %>
Answer: a
49. What is the difference between include and forward in JSP?
a. Include forwards the control to another page
b. Forward includes the content of another page
c. Include includes the content of another page
d. Forward forwards the control to another JSP page
Answer: c
50. What is the syntax to set the content type of a JSP page?
a. <%@ page contentType=”text/html; charset=UTF-8″ %>
b. <%@ directive contentType=”text/html; charset=UTF-8″ %>
c. <% response.setContentType(“text/html; charset=UTF-8”); %>
d. All of the above
Answer: a
- Top 10 DevOps Trainers in the world - October 7, 2023
- What is Cookies and Why it is Used? - May 24, 2023
- TOP trends of transitions in TikTok - May 10, 2023