Platform independence: although Java is machine-independent, are JSPs themselves not machine-independent? Assess the claim in the context of servlet containers and bytecode portability.

Difficulty: Easy

Correct Answer: Invalid (JSPs compile to servlets/bytecode and are platform-independent under a JVM)

Explanation:


Introduction / Context:
JSPs are part of the Java web stack. Like Java classes, JSPs ultimately execute as bytecode inside a servlet container, which runs on any OS with a compatible JVM. This question examines whether JSPs lose Java’s portability benefits.


Given Data / Assumptions:

  • A standard Java servlet container (for example, Tomcat, Jetty) is available.
  • The application does not rely on OS-specific native libraries.
  • Java bytecode portability applies.


Concept / Approach:
A JSP is translated into a Java servlet and compiled to bytecode. The same .war file can be deployed on any supported OS where the container and JVM run. Any departure from portability stems from the application’s own native dependencies, not from JSP technology itself. Therefore, claiming JSPs are not machine-independent is incorrect.


Step-by-Step Solution:

JSP request enters container.Container translates JSP to a servlet and compiles to .class files.The servlet executes on the JVM, which is cross-platform.Hence, JSPs retain Java’s portability properties.


Verification / Alternative check:
Deploy the same WAR on Windows, Linux, and macOS Tomcat instances; behavior is identical given the same JVM and configuration.


Why Other Options Are Wrong:

  • Browser engines and OS choices are irrelevant to server-side execution.
  • JDBC driver type does not negate JVM-level portability.


Common Pitfalls:
Confusing server-side portability with client-side differences; relying on native binaries in the app, which do reduce portability.


Final Answer:
Invalid (JSPs compile to servlets/bytecode and are platform-independent under a JVM)

Discussion & Comments

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