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

  • Home
  • SEARCH
  • 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 6364169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:07:48+00:00 2026-05-25T00:07:48+00:00

I have created Sample.java servlet, it is in src folder. and created HTML page

  • 0

I have created Sample.java servlet, it is in src folder.

and created HTML page in pages directory i.e, pages/First.html

Now I need to provide in servlet mapping as pages/Sample that I am not getting why pages directory name should mention in servlet url mapping.

As it is in root folder.

  • 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-25T00:07:48+00:00Added an answer on May 25, 2026 at 12:07 am

    You should never put any class in the root package.

    Once you have put your Sample class in a package (example: com.foo.andy.sample), you need to declare the servet in the web.xml of your web application, and declare one (at least) mapping for this servlet.

    You might follow this tutorial to know how to do it.

    You need these lines in the web.xml:

    <servlet>
        <servlet-name>SampleServlet</servlet-name>
        <servlet-class>com.foo.andy.sample.Sample</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>SampleServlet</servlet-name>
        <url-pattern>/pages/Sample</url-pattern>
    </servlet-mapping>
    

    And your servlet will be accessible at …/yourWebApp/pages/Sample

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

Sidebar

Related Questions

Hi I have created a sample java swing application Mac os. Now I want
I have created a sample java socket application. I used Socket s = new
I have created a sample report with crystal report 10. Now, I wanna to
Hi I am using 64bit Fedora 10 linux. I have created a sample java
I have created one GUI using Swing of Java. I have to now set
I have created some simple app in Java, and 'deployed' it using Java Web
I have created a simple web-service using Java. i want to load jars related
I created the sample WAR as given at the Compojure Getting Started Page and
I have created simple Java Dynamic Web project in Eclipse. I host my project
I have created sample namespace: [demas @arch.local.net ][~/dev/projects/diary]% cat shell_space.clj (ns shell_space) (defn test_fu

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.