JSP authoring model: “With JavaServer Pages (JSP), all coding is done in Java and only in Java.” Assess this claim considering JSP tags, Expression Language (EL), and templating.

Difficulty: Easy

Correct Answer: Incorrect

Explanation:

Introduction / Context:JSP is a view technology that mixes template markup with server-side behavior. While early JSP encouraged scriptlets (embedded Java), modern JSP emphasizes tag libraries and Expression Language to reduce Java code in pages.

Given Data / Assumptions:

  • JSP files commonly contain HTML or other markup.
  • JSTL and custom tags encapsulate logic without raw Java.
  • EL provides concise access to attributes and beans.

Concept / Approach:The claim “only in Java” is incorrect. JSP supports multiple constructs: static markup, JSP directives, standard/custom tags, and EL. Java classes (servlets, beans, tag handlers) implement behavior outside the JSP view, promoting separation of concerns.

Step-by-Step Solution:Design the view with HTML/CSS.Use JSTL core tags for iteration/conditions instead of scriptlets.Bind model data via request/session attributes and EL.Move complex logic into Java classes (controllers, services).Configure via web.xml or annotations; JSP compiles to a servlet.

Verification / Alternative check:Inspect typical JSPs in modern projects: minimal or no raw Java, heavy use of tags/EL.

Why Other Options Are Wrong:Restricting to scriptlets is outdated and not required; pre–JSP 2.0 still allowed tags.

Common Pitfalls:Embedding business logic in JSPs; overusing scriptlets and hurting maintainability.

Final Answer:Incorrect

More Questions from JDBC, Java Server Pages, and MySQL

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion