Van het gegeven voorbeeld wordt van u verwacht dat u uw webtoepassing in uw Tomcat implementeert als MyFirstServlet.war (of als een ontbrekende map - dit maakt geen verschil) en laat u uw GrettingServlet toewijzen aan de -toepassingsdirectory - als je wilt dat de servlet met de root gaat werken:
Uw /WEB-INF/web.xml
moet deze als volgt hebben:
GrettingServlet
your.package.GrettingServlet
1
GrettingServlet
/
Note the typo: "Gretting" (in servlet and mappings) vs "Greeting" (in JSP form)
Bij uw opstelling moet u uw browser naar http://localhost: 8080/MyFirstServlet/GrettingServlet
wijzen om naar de servlet te gaan.
If your idea is to have JSP page to handle the root, then you should browse to either http://localhost:8080/MyFirstServlet/.jsp
or have the JSP called index.jsp
or default.jsp
(see
section of your web.xml
). In this case your idea, I guess, is to display a JSP and then post to the servlet, therefore make sure your servlet specification and mapping is correct (web.xml
servlet mapping and the JSP form action
attribute).