Category Archives: Без рубрики

Java.Servlet.What authentication methods are available to a servlet?

✅ Short Answer: In servlets, there are four standard authentication methods, defined by the Servlet Specification (web.xml or annotations). Method Description 1. Basic Authentication Simple login popup from the browser (username/password sent base64-encoded). 2. Digest Authentication Like Basic but sends … Continue reading

Posted in Без рубрики | Leave a comment

Java.Servlet.What are the main features introduced in the Servlet 3 specification?

✅ Short answer: Servlet 3.0 (finalized in December 2009, part of Java EE 6) brought major improvements to simplify development and support modern web applications. ✅ Main Features introduced in Servlet 3.0: Feature Description 1. Annotation-based Configuration No more messy … Continue reading

Posted in Без рубрики | Leave a comment

Java.Servlet.Should i close connection in my code if i use connection pool ?

✅ Short and clear answer:YES, you absolutely must close the Connection yourself even when using a connection pool! BUT — and this is very important — Closing a connection from the pool does NOT physically close it to the database. … Continue reading

Posted in Без рубрики | Leave a comment

Java.Servlet.If i created connection pool, when it should be destroyed ?

✅ Short answer:The connection pool (like HikariDataSource, Tomcat DataSource, etc.) should be destroyed when the web application is shutting down. That means: When Tomcat (or another servlet container) undeploys your app, Or stops, Or reloads the application. Otherwise: Database connections … Continue reading

Posted in Без рубрики | Leave a comment

Java.Servlet.How can we organize a database connection, provide logging in a servlet?

✅ Problem: You need a database connection in your servlet. You want to log information, warnings, errors (instead of just printing to console). If you just open a Connection inside every servlet → it’s inefficient and dangerous (resource leaks, no … Continue reading

Posted in Без рубрики | Leave a comment

Java.Servlet.How can we provide transport layer security for our web application?

✅ Short answer:To provide Transport Layer Security (TLS) for your web application, you must use HTTPS instead of HTTP. TLS = modern version of SSL (Secure Sockets Layer).It encrypts all the data sent between the client (browser) and server, preventing: … Continue reading

Posted in Без рубрики | Leave a comment

Java.Servlet.What is an effective way to ensure that all servlets are accessible only to a user with a valid session?

✅ Short answer:The most effective and standard way is to use a Servlet Filter. A Filter intercepts every request before it reaches the servlet. In the filter, you check if the user has a valid session. If the session is … Continue reading

Posted in Без рубрики | Leave a comment

Java.Servlet.How can we notify an object in a session that the session is invalid or expired?

✅ Short answer:You can notify an object in the session about session invalidation or expiration by making the object implement the HttpSessionBindingListener or HttpSessionActivationListener interface. These special interfaces allow session attributes (objects stored inside the session) to get “events” when … Continue reading

Posted in Без рубрики | Leave a comment

Java.Servlet.What is session ?

✅ “Session” in web development means:A way to remember a user’s data between different HTTP requests. Because HTTP is stateless by design: Every request is independent. The server doesn’t remember if two requests come from the same user. So a … Continue reading

Posted in Без рубрики | Leave a comment

Java.Servlet.What exactly encodeRedirectURL does ?

✅ First: What is sendRedirect() doing?When you call: the server tells the browser:“Hey browser, make a new request to somepage.jsp!”(using an HTTP 302 Redirect response). BUT: If cookies are disabled, you still want the session (like login information) to continue … Continue reading

Posted in Без рубрики | Leave a comment