Need help in using Eclipse Java EE version to develop a servlet project
I have downloaded Eclipse Java EE version (3.5) 开发者_运维知识库and I would like to use it to develop a servlet project on tomcat.
So I
- install tomcat and add it as my server in my eclipse environment.
- create a Dynamic Web Project called 'TestServlet'
- create a new servlet called 'MainServlet'
and then I deploy my project to the tomcat server via eclipse and 'run the server in debug' mode.
But when I use the browser to hit http://localhost:8080/TestServlet/MainServlet
I see no resource found (that page is generated by Tomcat, so I know my Tomcat is running).
Can you please tell me what am I missing? Or how can I trouble shoot my problem?
I think it must be some path /name is not set correctly.
Take a look at your web.xml file in your project. You should find an entry for your servlet and a mapping.
<servlet> <servlet-name>MainServlet</servlet-name> <servlet-class>your.package.MainServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>MainServlet</servlet-name> <url-pattern>/main.do</url-pattern> </servlet-mapping>
Then the URL you use to access the servlet is:
http://localhost:8080/main.do
Verify your servlet mapping is correct in web.xml
Did you declare your Servlet in the deployment descriptor (the web.xml
file)? How did you map it? I suggest to check the Servlet and JSP development with Eclipse WTP - Tutorial or any other tutorial.
精彩评论