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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:33:27+00:00 2026-06-12T03:33:27+00:00

I’ve just started working on servlets and i’m a newbie. I have developed a

  • 0

I’ve just started working on servlets and i’m a newbie.
I have developed a html page with a drop-down menu from which the user can select the color of beer and there is a submit button which invokes the servlet.Here is the html code for it.

<html>
<head>
<title>Beer Selection</title>
</head>
<body>
<h2>Beer Selection Page</h2>
<p>Select beer charecteristics:</p>
<hr>
<form method="POST" action="SelectBeer.do">
    <b>Color :</b><!--Keeping it outside the form unnecessarily creates a line break between color and Drop-down menu-->
    <select name="color">
        <option>Light</option>
        <option>Brown</option>
        <option>Amber</option>
        <option>Dark</option>
    </select><br>
    <input type="SUBMIT" value="SUBMIT">
</form>
</body>
</html>

I have created the following deployment descriptor

<?xml version="1.0" encoding="UTF-8"?>
<web-app 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/web-app_2_5.xsd"
version="2.5">
<servlet>
<servlet-name>MyBeer</servlet-name>
<servlet-class>com.example.web.BeerSelect</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>MyBeer</servlet-name>
<url-pattern>/SelectBeer.do</url-pattern>
</servlet-mapping>
</web-app>

I have also successfully compiled the BeerSelect.java servlet whose code is given below

package com.example.web;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class BeerSelect extends HttpServlet
{
public void doPost(HttpServletRequest request,HttpServletResponse response)throws IOException,ServletException
{
    response.setContentType("text/html");
    PrintWriter out=response.getWriter();
    out.println("Beer Selection Advice<br>");
    String c=request.getParameter("color");
    out.println("<br>Got Beer color"+c);
}
}

I am using tomcat 7.0.21 and i have created the directories as follows:
tomcat/webapps/learning/Beer-v1/form.html and
tomcat/webapps/learning/Beer-v1/WEB-INF/web.xml and
tomcat/webapps/learning/Beer-v1/WEB-INF/classes/com/example/web/BeerSelect.class
(learning is just a folder in which i keep all my small servlet and jsp projects in webapps
Inside learning i’ve my different project such as Beer-v1,DateDisplay,HotelMgmt,etc.)

Now when i run the form.html inside tomcat it is properly displayed but when i click on submit it shows

HTTP Status 404 - /learning/Beer-v1/SelectBeer.do

type Status report

message /learning/Beer-v1/SelectBeer.do

description The requested resource (/learning/Beer-v1/SelectBeer.do) is not available.
Apache Tomcat/7.0.21

what am i doing wrong .Please help.

  • 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-12T03:33:29+00:00Added an answer on June 12, 2026 at 3:33 am

    It should work if you have Beer-v1 as a direct subfolder of the Tomcat’s webapp folder.
    Then try to access [tomcaturl]/Beer-v1/[yourhtmlform].html.

    Because you mapped your servlet to the context root (which is /), there is no mapping for a /learning/Beer-v1/SelectBeer.do.

    IMHO it is not a very good idea to have your workspace folder structure inside Tomcat’s webapp folder. This is a special folder for deployed webapps, and Tomcat is expecting a kind of standard structure for this folder (WEB-INF inside root directory, for example).

    I think it is better to use Eclipse or something that deploys your application (from your filesystem) to Tomcat automatically. This way you can have your workspace managed however you want.

    Eclipse maintains a so called ‘workspace’ where it stores all projects that you create with it. The first time you start Eclipse it will ask you which folder to use as workspace. You could then name your ‘learning’ folder as you use it at the moment.

    When you add a server execution environment to Eclipse (e.g. a Tomcat installation), you can configure how Eclipse deploys. The default configuration is to copy the webapp to a Eclipse specific workspace subfolder.

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

Sidebar

Related Questions

I have a text area in my form which accepts all possible characters from
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have an autohotkey script which looks up a word in a bilingual dictionary
I have an array which has BIG numbers and small numbers in it. I
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have thousands of HTML files to process using Groovy/Java and I need to
I have a view passing on information from a database: def serve_article(request, id): served_article

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.