Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6908885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:37:08+00:00 2026-05-27T08:37:08+00:00

I need to run my servlet on a server with a running tomcat. I

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:37:09+00:00Added an answer on May 27, 2026 at 8:37 am

    There are in this particular case 2 potential causes:

    1. Tomcat isn’t configured to hotdeploy after a web.xml edit. You need to restart Tomcat manually.

    2. The particular Tomcat setup doesn’t support servlet classes in the default package. You should always put the class in a package if the class is intented to be used by another classes which are by itself inside a package (such as Tomcat internal classes).

    See also:

    • Tomcat can't find class that is placed directly under classes folder

    Unrelated to the concrete problem, I understand that you’re just getting started with servlets, I will however point out that this isn’t the "best practice" to use servlets. I suggest to take a look in our servlets wiki page to get some concrete examples, learn about the canonical approaches and find links to proper tutorials.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to connect from a standalone applet to a servlet running on tomcat:
Given a Java Servlet (running on a Windows server) which creates a new process
I need to create a persistent Java based application that will run at set
I need to create a WS with Spring 3.0.4.RELEASE to run in a Tomcat
i need run code that will create a database and populate tables. i am
I need to run a stored procedure from a C# application. I use the
I need to run a Linux CLI command and get its stdout output from
I need to run a RLIKE query on a database mmoved from MySQL to
I need to upload image to the server, where SmartGWT webapplication is running... after
An existing Java site is designed to run under / on tomcat and there

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.