Cpanel和Tomcat 7 servlet映射

时间:2013-10-04 12:36:50

标签: java tomcat servlets cpanel web.xml

我尝试在cpanel tomcat 7上运行servlet,但似乎它不起作用。当我在jsp文件中运行servlet时没关系,但映射servlet不起作用。

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<servlet>
    <servlet-name>TestServlet</servlet-name>
    <servlet-class>com.i_do2.java.TestServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>TestServlet</servlet-name>
    <url-pattern>/TestServlet</url-pattern>
</servlet-mapping>
<welcome-file-list>
    <welcome-file>indexp.jsp</welcome-file>
</welcome-file-list>
<session-config>
    <session-timeout>
        30
    </session-timeout>
</session-config>

当我运行www.mydomain.com/TestServlet时,我找不到错误404,看来cpanel上的tomcat没有读取web.xml文件,你能帮我在cpanel中配置这个吗?

上下文设置为root“/”

1 个答案:

答案 0 :(得分:0)

"./TestServlet"放入表单操作属性

<form action="./TestServlet">
//do your stuff here
</form>

直接调用servlet

for localhost

 1.http://localhost:8080/TestServlet

适用于您的域名

 2. http://DOMAIN PATH :APCHE TOMCAT PATH/TestServlet