Then use the same javac HelloWorld.java to compile this document, if there is no import javax.servlet .*
So that should be C: \ Tomcat \ common \ lib inside servlet.jar copy files to the C: \ JDK \ jre \ lib \ ext, again compiled, there will be no problem!
Tomcat then the directory C: \ Tomcat \ webapps \ ROOT inside the file structure as follows:
ROOT \ index.html
ROOT \ welcom.jsp
ROOT \ WEB-INF \ lib \ MyServlet.jar (If your servlet's. Fight a class. Jar file, on the lib below)
ROOT \ WEB-INF \ classes \ HelloWorld.class (HelloWorld.class the above documents generated on the inside)
Then enter http://localhost:8080/servlet/HelloWorld browser, the popular will and therefore Server error: Error 404 - Not Found
How all?
Servlet must use the C: \ Tomcat \ webapps \ ROOT \ WEB-INF directory of the following web.xml file registration with the EP open web.xml file,
On the inside to join
HelloWorld
HelloWorld
HelloWorld
/ Servlet / helloworld
This structure
HelloWorld
HelloWorld
That the designation includes servlet class.
And the following structure
HelloWorld
/ Servlet / HelloWorld
HelloServlet that should be designated where a URL mapping mode.
After revising the web.xml finished, restart Server, and then enter http://localhost:8080/servlet/HelloWorld, then lined a Hello, World! Waiting for you? Congratulate you get the:)
Amat, a tired hands, wrote on it here, it is hoped that role for beginners!
Saturday, August 2, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment