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
you need to define welcome file list. see http://download.oracle.com/javaee/1.4/tutorial/doc/WebApp4.html
http://wiki.apache.org/tomcat/HowTo#How_do_I_override_the_default_home_page_loaded_by_Tomcat.3F
I see a Facelets page and I see a JSF specific <context-param>
, 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 <url-pattern>
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 <url-pattern>
to /greeting
instead.
Yes, you need define index page for your web app and you can make redirect inside f.e. create page index.html with this contect
<html><head><meta http-equiv="REFRESH" content="0; url=greeting/"></head></html>
and then in web.xml
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>