There is a java servlet:
import java.io.*; import java.util.Date; import javax.servlet.*; import javax.servlet.http.*; public class CurrentDate extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); String title = "Display Current Date & Time"; Date date = new Date(); String docType = "<!doctype html public \"-//w3c//dtd html 4.0 " + "transitional//en\">\n"; out.println(docType + "<html>\n" + "<head><title>" + title + "</title></head>\n" + "<body bgcolor=\"#f0f0f0\">\n" + "<h1 align=\"center\">" + title + "</h1>\n" + "<h2 align=\"center\">" + date.toString() + "</h2>\n" + "</body></html>"); } } When launched, the browser displays the index.jsp page, and not the result of the servlet. Netbeans IDE 8.2. In older versions of Netbeans, there was no such problem, as I recall.
web.xml:
<?xml version="1.0" encoding="UTF-8"?> <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> <servlet> <servlet-name>CurrentDate</servlet-name> <servlet-class>CurrentDate.CurrentDate</servlet-class> </servlet> <servlet-mapping> <servlet-name>CurrentDate</servlet-name> <url-pattern>/CurrentDate</url-pattern> </servlet-mapping> <session-config> <session-timeout> 30 </session-timeout> </session-config> </web-app>
<welcome-file-list> <welcome-file>CurrentDate</welcome-file> </welcome-file-list>- Morewind