java - Can't deploy application to Tomcat -
i tried start tomcat 7.
created application in eclipse. here web.xml file:
<?xml version="1.0" encoding="utf-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemalocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" id="webapp_id" version="2.4"> <welcome-file-list> <welcome-file> view.jsp </welcome-file> </welcome-file-list> <servlet> <servlet-name>myservlet</servlet-name> <servlet-class>/servlets/myservlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>myservlet</servlet-name> <url-pattern>/myservlet</url-pattern> </servlet-mapping> </web-app> i downloaded lastest tomcat apache's site, , added java_home catalina.bat. after starting tomcat went in manager app , chose application got 404. in address line - http://localhost:8080/threerest/.
strange thing application didn't deploy webapps directory wtpwebapps folder.
my other problem tomcat-users.xml. if add this:
<role rolename="manager"/> <role rolename="manager-gui"/> <role rolename="admin"/> <user username="tomcat" password="tomcat" roles="admin,manager,manager-gui"/> its work in 1 session. when stop tomcat removed file.
<servlet-class> should be
<servlet-class>servlets.myservlet</servlet-class> because specify package here not path.
please note must access website @ either
http://localhost:8080/threerest/myservlet or
http://localhost:8080/threerest/ with view.jsp @ web-app's root folder.
edit: once deployed web application's folder structure should like: (/ indicates directory)
tomcat-home/ |- webapps/ |- rest/ //<-- context-root (web-app's name) |- view.jsp //<-- *.html, *.jsp files |- web-inf/ |- web.xml |- lib/ |- *.jar files |- classes/ //<-- servlets go here |- servlets/ //<-- required package/folder structure |- myservlet.class
Comments
Post a Comment