Member 13700491 Ответов: 0

Проблема при развертывании файла java war в общедоступном домене ?


Я построил свой проект в Eclips и сгенерировал файл *.war со следующей структурой контента:

E-commerse
  --->src
         -->com.servlet
                    ---->Test.java
  --->Webcontent
         -->Web-INF
                    ---->Web.xml
                    ---->classes
                           --->Test.class   
         -->index.html


Он будет работать с localhost,но при развертывании файла war в общедоступном домене он показывает Запрошенный URL-адрес /WebApplication1/Test не был найден на этом сервере. когда я вызываю сервлет

Что я уже пробовал:

index.html
<html>
<head>
<title>Sample "Hello, World" Application</title>
</head>
<body bgcolor=white>
<table border="0">
<tr>
<td>
<img src="images/tomcat.gif">
</td>
<td>
<h1>Sample "Hello, World" Application</h1>
<p>This is the home page for a sample application used to illustrate the
source directory organization of a web application utilizing the principles
outlined in the Application Developer's Guide.
</td>
</tr>
</table>
<p>To prove that they work, you can execute either of the following links:
<ul>
<li>To a <a href="Test">servlet</a>.
</ul>
</body>
</html>


Test.java

package com.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public final class Test
  extends HttpServlet
{
  public Test() {}
  public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
  {
    response.setContentType("text/html");
    PrintWriter writer = response.getWriter();
    writer.println("<html>");
    writer.println("<head>");
    writer.println("<title>Sample Application Servlet Page</title>");
    writer.println("</head>");
    writer.println("<body bgcolor=white>");
    writer.println("<table border=\"0\">");
    writer.println("<tr>");
    writer.println("<td>");
    writer.println("<img src=\"images/tomcat.gif\">");
    writer.println("</td>");
    writer.println("<td>");
    writer.println("<h1>Sample Application Servlet</h1>");
    writer.println("This is the output of a servlet that is part of");
    writer.println("the Hello, World application.");
    writer.println("</td>");
    writer.println("</tr>");
    writer.println("</table>");
    writer.println("</body>");
    writer.println("</html>");
  }
}


web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/n/j2ee/web-app_2_4.xsd"
    version="2.4">

    <display-name>Hello, World Application</display-name>
    <description>
	This is a simple web application with a source code organization
	based on the recommendations of the Application Developer's Guide.
    </description>
    <servlet>
        <servlet-name>Test</servlet-name>
        <servlet-class>com.servlet.Test</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>Test</servlet-name>
        <url-pattern>/Test</url-pattern>
    </servlet-mapping>
</web-app>

0 Ответов