Notice: Due to an ongoing migration of our storage and publishing system, material requested since last month will not be uploaded for the time being, and new requests are paused. All existing notes remain available.

Unit 4 MCQs JavaServer Pages

CSE406 — Advanced Java Programming 60 questions. Pick an option to check it.

Read the notes Subjective questions

0 of 60 answered 0 right 0 wrong , 60 left

  1. Question 1 of 60 Lifecycle of a JSP page Easy

    What happens first when a JSP page is requested and has not yet been compiled?

  2. Question 2 of 60 Lifecycle of a JSP page Easy

    Which JSP lifecycle method is normally called only once after the servlet instance is created?

  3. Question 3 of 60 Lifecycle of a JSP page Easy

    Which method processes each client request for a JSP page?

  4. Question 4 of 60 Lifecycle of a JSP page Easy

    Which method is called before a JSP servlet is removed from service?

  5. Question 5 of 60 Directory structure of JSP Easy

    Which directory commonly stores compiled Java classes in a Java web application?

  6. Question 6 of 60 Directory structure of JSP Easy

    Which directory commonly stores JAR library files for a JSP web application?

  7. Question 7 of 60 Directory structure of JSP Easy

    What is generally true about a JSP file placed inside the WEB-INF directory?

  8. Question 8 of 60 JSP API Easy

    Which package traditionally contains the core JSP API classes and interfaces?

  9. Question 9 of 60 JSP API Easy

    Which JSP API class provides access to page-related attributes and servlet objects?

  10. Question 10 of 60 Scriptlet tag Easy

    Which syntax represents a JSP scriptlet tag?

  11. Question 11 of 60 Scriptlet tag Easy

    What can be written inside a JSP scriptlet?

  12. Question 12 of 60 Expression tag Easy

    Which syntax is used for a JSP expression?

  13. Question 13 of 60 Expression tag Easy

    What is the main purpose of a JSP expression tag?

  14. Question 14 of 60 Declaration tag Easy

    Which syntax represents a JSP declaration tag?

  15. Question 15 of 60 Declaration tag Easy

    What is commonly declared using a JSP declaration tag?

  16. Question 16 of 60 JSP implicit objects Easy

    Which JSP implicit object represents the client's HTTP request?

  17. Question 17 of 60 JSP implicit objects Easy

    Which JSP implicit object is used to write content to the response?

  18. Question 18 of 60 JSP implicit objects Easy

    Which JSP implicit object stores data associated with a user's session?

  19. Question 19 of 60 JSP action tags Easy

    Which JSP action tag includes another resource while processing the current request?

  20. Question 20 of 60 JSP action tags Easy

    Which JSP action tag transfers request processing to another resource?

  21. Question 21 of 60 Lifecycle of a JSP page Medium

    A JSP page is requested for the first time after deployment. Which sequence best represents the major lifecycle stages performed by the container?

  22. Question 22 of 60 Lifecycle of a JSP page Medium

    A JSP needs to open a database connection pool once when its generated servlet is initialized and release it before the servlet is removed. Which methods are most appropriate?

  23. Question 23 of 60 Lifecycle of a JSP page Medium

    A JSP file is modified after it has already handled several requests. What will a typical JSP container do on the next request?

  24. Question 24 of 60 Directory structure of JSP Medium

    A JSP imports the class com.example.Cart, which is not packaged in a JAR. Where should Cart.class be placed in the web application?

  25. Question 25 of 60 Directory structure of JSP Medium

    A developer wants reports.jsp to be accessible only through a server-side forward, not by entering its URL directly. Which location is most suitable?

  26. Question 26 of 60 JSP API Medium

    A JSP writes a large amount of generated text using the implicit out object. What is the declared JSP API type of this object?

  27. Question 27 of 60 JSP API Medium

    The same attribute name exists in page, request, session, and application scopes. Which value is returned by pageContext.findAttribute("status")?

  28. Question 28 of 60 JSP API Medium

    Which statement correctly describes the _jspService() method defined by the JSP servlet model?

  29. Question 29 of 60 Scriptlet tag Medium

    Which JSP fragment correctly uses a scriptlet to display Adult only when the request parameter age represents a value of at least 18?

  30. Question 30 of 60 Scriptlet tag Medium

    Consider the fragment <% int total = 0; total++; %>. Where is total normally declared in the generated servlet?

  31. Question 31 of 60 Expression tag Medium

    Which scriptlet is functionally equivalent to the JSP expression <%= product.getPrice() %>?

  32. Question 32 of 60 Expression tag Medium

    A page contains <%= request.getParameter("name").toUpperCase() %>. What happens if the request has no name parameter?

  33. Question 33 of 60 Declaration tag Medium

    A JSP must define a helper method named formatName that can be called from multiple expressions in the page. Which syntax declares it as a generated servlet member?

  34. Question 34 of 60 Declaration tag Medium

    A JSP contains <%! int visits = 0; %> followed by <%= ++visits %>. Why can the displayed count be unreliable under concurrent requests?

  35. Question 35 of 60 JSP implicit objects Medium

    A custom error page needs to display the exception that caused request processing to fail. Which configuration makes the implicit exception object available?

  36. Question 36 of 60 JSP implicit objects Medium

    A JSP declares <%@ page session="false" %>. Which implicit object is unavailable to that page?

  37. Question 37 of 60 JSP implicit objects Medium

    A value must be shared by all users and all JSP pages within the same deployed web application. Which implicit object should store it?

  38. Question 38 of 60 JSP action tags Medium

    A JSP must include the current output of menu.jsp every time the page is requested. Which standard action is most appropriate?

  39. Question 39 of 60 JSP action tags Medium

    A JSP has already flushed its response buffer and then executes <jsp:forward page="login.jsp" />. What is the most likely result?

  40. Question 40 of 60 JSP action tags Medium

    Consider <jsp:useBean id="cart" class="shop.Cart" scope="session" />. What happens when the session already contains an attribute named cart of the expected type?

  41. Question 41 of 60 Lifecycle of a JSP page Hard

    For the first successful request to a newly deployed JSP that has not been precompiled, which lifecycle sequence is correct?

  42. Question 42 of 60 Lifecycle of a JSP page Hard

    A JSP contains the declaration <%! public void _jspService(HttpServletRequest r, HttpServletResponse s) { } %>. What is the expected result?

  43. Question 43 of 60 Directory structure of JSP Hard

    A JSP is deployed as /WEB-INF/reports/summary.jsp. Which statement about accessing it is correct?

  44. Question 44 of 60 Directory structure of JSP Hard

    A loose compiled class has the binary name com.acme.Report and must be visible to JSP pages in a standard WAR. Where should it be placed?

  45. Question 45 of 60 JSP API Hard

    Which statement correctly describes the relationship among the core JSP page interfaces?

  46. Question 46 of 60 JSP API Hard

    A buffered JspWriter has already flushed some content to the client. Which distinction between clear() and clearBuffer() is correct?

  47. Question 47 of 60 Scriptlet tag Hard

    Assuming no surrounding whitespace, what is produced by <% for (int i = 0; i < 2; i++) { %><%= i %><% } %>?

  48. Question 48 of 60 Scriptlet tag Hard

    What happens when a JSP contains <% int calculate() { return 42; } %> inside a scriptlet?

  49. Question 49 of 60 Expression tag Hard

    What is the result of placing <%= response.flushBuffer() %> in a JSP?

  50. Question 50 of 60 Declaration tag Hard

    Why does <%! String user = request.getParameter("u"); %> normally fail to compile?

  51. Question 51 of 60 Declaration tag Hard

    A JSP declares <%! int hits = 0; %> and executes <% hits++; %> for every request. Under the usual servlet threading model, which statement is correct?

  52. Question 52 of 60 JSP implicit objects Hard

    The attribute key exists in all four standard scopes with different values. What does pageContext.findAttribute("key") return?

  53. Question 53 of 60 JSP implicit objects Hard

    A source JSP specifies <%@ page errorPage="failure.jsp" %>. Under what condition can failure.jsp directly use the implicit object exception?

  54. Question 54 of 60 JSP implicit objects Hard

    A JSP begins with <%@ page session="false" %> and later contains <%= session.getId() %>. What is the expected outcome?

  55. Question 55 of 60 JSP action tags Hard

    A parent JSP was translated yesterday. Today, fragment.jsp is modified, but the parent is not retranslated. Which mechanism is designed to use the fragment's current request-time output?

  56. Question 56 of 60 JSP action tags Hard

    A JSP writes content into an uncommitted response buffer and then executes <jsp:forward page="target.jsp" />. What should occur?

  57. Question 57 of 60 JSP action tags Hard

    A request-scope bean named c already exists with count = 9. What happens here: <jsp:useBean id="c" class="com.acme.Counter" scope="request"><jsp:setProperty name="c" property="count" value="1" /></jsp:useBean>?

  58. Question 58 of 60 JSP action tags Hard

    No attribute named items exists in request scope. What happens with <jsp:useBean id="items" type="java.util.List" scope="request" />?

  59. Question 59 of 60 JSP action tags Hard

    A bean initially has name = "Mira", age = 4, and active = true. The request parameters are age=12 and extra=x. After <jsp:setProperty name="person" property="*" />, what state is expected?

  60. Question 60 of 60 JSP action tags Hard

    The original request contains mode=old, and a JSP performs <jsp:include page="target.jsp"><jsp:param name="mode" value="new" /></jsp:include>. What does request.getParameter("mode") return inside target.jsp?

That's unit 4

Answer a few questions and your score shows up here.