What will be the value of ‘val’ displayed when JSP page is accessed for the…

2024

What will be the value of ‘val’ displayed when JSP page is accessed for the third time since server startup? <%! int val = 0; %> <% val++; %> <html><body><p> val: <%= val %> </p></body></html>

Answer: C. 3The JSP declaration creates an instance variable val initialized to 0. Each request increments it once, so on the third access the displayed value is 3.

  1. A.

    1

  2. B.

    2

  3. C.

    3

  4. D.

    The value of val will remain 0

  5. E.

    Question not attempted

Attempted by 182 students.

Show answer & explanation

Correct answer: C

The JSP declaration creates an instance variable val initialized to 0. Each request increments it once, so on the third access the displayed value is 3.

Explore the full course: Uppsc Polytechnic Lecturer 2025 Cs

Loading lesson…