Question:

Which is the correct syntax for declaring a variable in JSP?

Show Hint

Use <%! %> for declarations and <%= %> for expressions in JSP.
Updated On: June 02, 2025
  • <%= declaration %>
  • <% declaration %>
  • <%! declaration %>
  • <% \# declaration %>
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is C

Solution and Explanation

In JSP, the correct way to declare variables and methods is using the declaration tag: <%! ... %>
This adds the code to the servlet's class level, making it accessible throughout the servlet.
Was this answer helpful?
0
0

TS PGECET Notification