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 8123367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:09:34+00:00 2026-06-06T06:09:34+00:00

I created dynamic web project , and add 2 items : index.jsp page like

  • 0

I created dynamic web project , and add 2 items :

  1. index.jsp page like this :

    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
        pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
            <form action="GrettingServlet" method="POST">
            First Name: <input type="text" name="firstName" size="20"><br>
            Last Name: <input type="text" name="lastName" size="20">
            <br><br>
            <input type="submit" value="Submit">
    </form> 
    
    </body>
    </html>
    
  2. in default package servlet like this (called GrettingServlet.java):

    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 class GrettingServlet extends HttpServlet {
        private static final long serialVersionUID = 1L;
    
        public GrettingServlet() {
            super();
        }
    
        protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            // TODO Auto-generated method stub
        }
    
        protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            response.setContentType("text/html;charset=UTF-8");
            PrintWriter out = response.getWriter();
            String firstName = request.getParameter("firstName").toString();
            String lastName = request.getParameter("lastName").toString();
    
            out.println("<html>");
            out.println("<head>");
            out.println("<title>Servlet GreetingServlet</title>");
            out.println("</head>");
            out.println("<body>");
            out.println("<p>Welcome " + firstName + " " + lastName + "</p>");
            out.println("</body>");
            out.println("</html>");
    
            out.close();
        }
    
    }
    

I installed tomcat6 so that I have Apache Software Foundation folder .
finally I want to create war file of this project, so I chose on the project Export>War file and in the Destination text I chose the webapps folder in the path C:\Program Files (x86)\Apache Software Foundation\Tomcat 6.0\webapps .
the project called MyFirstServlet . and in order to see the form of index.jsp on the server i write in the browser http://localhost:8080/MyFirstServlet/ but I get the message

HTTP Status 404 - /MyFirstServlet/

type Status report

message /MyFirstServlet/

description The requested resource (/MyFirstServlet/) is not available.

Apache Tomcat/6.0.35

the servlet mapping is this :

<?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/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>MyFirstServlet</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  <servlet>
    <description>new</description>
    <display-name>GrettingServlet</display-name>
    <servlet-name>GrettingServlet</servlet-name>
    <servlet-class>GrettingServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>GrettingServlet</servlet-name>
    <url-pattern>/GrettingServlet</url-pattern>
  </servlet-mapping>
</web-app>

I checked the tomcat and it on service status : started

What can be the problem ?

  • 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-06-06T06:09:35+00:00Added an answer on June 6, 2026 at 6:09 am

    From the given example, you are expected to deploy your web application into your Tomcat as MyFirstServlet.war (or as an exploded directory – this makes no difference) and have your GrettingServlet mapped to the application root – if you want the servlet to handle the root:

    Your /WEB-INF/web.xml should have these so:

    <servlet>
        <servlet-name>GrettingServlet</servlet-name>
        <servlet-class>your.package.GrettingServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    
    <servlet-mapping>
        <servlet-name>GrettingServlet</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
    

    Note the typo: “Gretting” (in servlet and mappings) vs “Greeting” (in JSP form)

    With your setup you should be pointing your browser at http://localhost:8080/MyFirstServlet/GrettingServlet to reach the servlet.

    If your idea is to have JSP page to handle the root, then you should browse to either http://localhost:8080/MyFirstServlet/<yourJSPName>.jsp or have the JSP called index.jsp or default.jsp (see <welcome-file-list/> section of your web.xml). In this case your idea, I guess, is to display a JSP and then post to the servlet, therefore make sure your servlet specification and mapping is correct (web.xml servlet mapping and the JSP form action attribute).

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

Sidebar

Related Questions

I had created a dynamic web project. AS of now it has a jsp
I have created simple Java Dynamic Web project in Eclipse. I host my project
This is driving me crazy. I created a Dynamic Web Project in eclipse and
I have created a Dynamic Web Page project in Eclipse and coded a Servlet.
I am new in flex.I have created dynamic web project. Run it. It accessible
When i created the dynamic web project, i will have 2 folders with name
I am new for Dynamic Web Projects. I created a new Dynamic web project
I have created a web application using Jersey and Dynamic Web Project of Eclipse.
I am using Eclipse (J2EE Galileo) and have created a dynamic web project and
I've created a Dynamic Web Project in Eclipse. I have 2 beans, 1 @Entity

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.