I need to run my servlet on a server with a running tomcat.
I create my HelloWorld  servlet from the java file(HelloWorld.java).
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
{
    response.setContentType( "text/html" );
    PrintWriter out = response.getWriter();
    out.println("<html>");
    out.println("<head><title>Hello World</title></head>");
    out.println("<body><h1>HELLO WORLD</h1></body>");
    out.println("</html>");
    out.close();
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException
{
doGet( request, response );
}
}
Than I upload it on a server and run
javac HelloWorld.java
This command creates HelloWorld.class file which i put into WEB-INF/classes folder
Than I add some code to the web.xml file in the WEB-INF directory, so it looks like this
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 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_2_5.xsd">
        <display-name>My first Servlet</display-name> 
    <servlet> 
        <servlet-name>HelloWorldServlet</servlet-name> 
        <servlet-class>HelloWorld</servlet-class> 
    </servlet> 
    <servlet-mapping> 
        <servlet-name>HelloWorldServlet</servlet-name> 
            <url-pattern>/HW</url-pattern> 
    </servlet-mapping> 
</web-app>
Than i run a command
touch ~WEB-INF/web.xml
Now i try to access my HelloWorld servlet by entering URL like ~\HW.
But i get an error:
type Status report
message /group05/HW
description The requested resource (/group05/HW) is not available.
What would you recommend to do to fix it?
Thanks for considering my question.
 
     
     
    