Java Servlet URL Mapping

后端 未结 3 993
攒了一身酷
攒了一身酷 2021-01-26 04:56

i fairly new to java servlet.

Please forgive me if this question seems stupid.

I have add servlet mapping such as servlet class and url pattern using netbeans i

3条回答
  •  猫巷女王i
    2021-01-26 05:20

    I see a Facelets page and I see a JSF specific , but I don't see the JSF FacesServlet being definied in web.xml, yet you're fiddling with other servlets.

    Aren't you mixing the basic concepts/technologies? Admittedly, the JSP tutorial is missing in Java EE 6 tutorial, but to work with plain vanilla servlets, you'd usually use plain HTML or JSP instead of Facelets.

    Anyway, to invoke a servlet by URL, you need to ensure that the URL matches the of the servlet as is been definied in the web.xml. You've definied your GreetingDukeServlet to listen on URLs matching /GreetingDukeServlet. So the URL has to be http://localhost:8080/HelloDuke2/GreetingDukeServlet instead.

    If you actually want the URL to be http://localhost:8080/HelloDuke2/greeting instead, then you should change the to /greeting instead.

    See also:

    • Servlets info page - Contains a little hello world

提交回复
热议问题