Enterprise systems require high security and throughput. In this module, we will explore upload sanitization, JNDI connection pools, and Tomcat thread scaling.

5.1. Secure File Uploads & JNDI Connection Pooling

Definition: Securing upload processes against directory traversal, and managing pre-opened database connections via JNDI.

Core Working Principles:

// JNDI lookup
InitialContext ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/TestDB");
try (Connection conn = ds.getConnection()) { ... }
5-Marks Exam Scoring Points
  • RCE Prevention: Prevents remote code execution by storing files outside the web root.
  • Sanitizes file paths to prevent attackers from overwriting system files.
  • JNDI connection pooling eliminates the overhead of opening database connections for every request.

5.2. Tomcat Concurrency and Thread Pools

Definition: Analyzing Tomcat's thread allocation model to understand how request processing scales.

Core Working Principles:

5-Marks Exam Scoring Points
  • Thread pooling prevents the overhead of creating new threads for every request.
  • Blocking I/O processes one request per thread, limiting concurrent connections.
  • Non-blocking configurations allow a small number of threads to handle thousands of concurrent requests.