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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:20:14+00:00 2026-05-26T00:20:14+00:00

I am using Eclipse, Oracle 10g and Apache Tomcat. This is my 1st sample

  • 0

I am using Eclipse, Oracle 10g and Apache Tomcat. This is my 1st sample application, so I am trying to print table only. But it’s not working.

This is my source code. testtable.java

package com.sla;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.PreparedStatement;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/**
 * Servlet implementation class newuser_db
 */
public class testtable extends HttpServlet {
    private static final long serialVersionUID = 1L;
    PreparedStatement stmt=null;
    Connection con =null;
    ResultSet rs=null;

       /**
     * @see HttpServlet#HttpServlet()
     */
    public testtable() {
        super();
        // TODO Auto-generated constructor stub
    }
    @Override
    public void init() throws ServletException {
        // TODO Auto-generated method stub
        super.init();
        try
        {
            Class.forName("sun.Jdbc.Odbc.JdbcOdbcDriver");
        }
        catch (ClassNotFoundException ex)
        {
            ex.printStackTrace();
        }


        try
        {
            con =DriverManager.getConnection("Jdbc:odbc:servletdb","system","mahes12345");

        }
        catch(SQLException ex)
        {
            ex.printStackTrace();
        }



        // TODO Auto-generated method stub
    }

    @Override
    public void service(ServletRequest arg0, ServletResponse arg1)
            throws ServletException, IOException {
        // TODO Auto-generated method stub
        super.service(arg0, arg1);
        PrintWriter out=arg1.getWriter();

        out.println("<html>" +
                "<head>" +
                "<table border='3' bordercolor='red'>" +
                "<tr><th>FKUserId</th><" +
                "th>IncNo</th>" +
                "<th>Summary</th>" +
                "<th>Status</th>" +
                "<th>Priority</th>" +
                "<th>IncidetDate</th>" +
                "<th>ReportDate</th>" +
                "<th>Reopen</th>" +
                "<th>Attachment</th>" +
                "<th>RequestMode</th>" +
                "</tr><tr></tr>" +
                "</table></head></html>");


    }
    @Override
    public void destroy() {
        // TODO Auto-generated method stub
        super.destroy();
        try
        {
            if(stmt!=null)
                stmt.close();
            stmt=null;

        }
        catch (SQLException ex)
        {
            ex.printStackTrace();
        }
        try
        {
            if(con!=null)
                con.close();
            con=null;

        }
        catch (SQLException ex)
        {
            ex.printStackTrace();
        }
    }



    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub

    }


}

This is my web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <display-name>testtable</display-name>
    <servlet>
        <description>
        </description>
        <display-name>testtable</display-name>
        <servlet-name>testtable</servlet-name>
        <servlet-class>
        com.sla.testtable</servlet-class>
    </servlet>

    <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>
</web-app>

error

HTTP Status 404 - /testtable/servlet/com.sla.testtable

--------------------------------------------------------------------------------

type Status report

message /testtable/servlet/com.sla.testtable

description The requested resource (/testtable/servlet/com.sla.testtable) is not available.


--------------------------------------------------------------------------------

Apache Tomcat/5.5.28

How is this problem caused and how can I solve it?

  • 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-26T00:20:15+00:00Added an answer on May 26, 2026 at 12:20 am

    You forgot to map the servlet on an URL. Add the following below the <servlet> of your web.xml.

    <servlet-mapping>
        <servlet-name>testtable</servlet-name>
        <url-pattern>/yourservleturl</url-pattern>
    </servlet-mapping>
    

    This way it’s available by http://localhost:8080/testtable/yourservleturl. You can change /yourservleturl to whatever you want.

    See also:

    • Our servlets wiki page (contains some Hello World examples)

    Unrelated to the concrete problem: your servlet is not thread safe. Also, your servlet will crash whenever the webapp runs longer than the DB connection is allowed to be kept open according the DB server. Fix that accordingly as well.

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

Sidebar

Related Questions

Background Developing a simple web application (Eclipse + JBoss + Apache Tomcat) to generate
I am new to Eclipse. Currently developing a sample web application using primefaces 3.1
This is my first Java application I am creating (using Eclipse IDE) and the
We are using an Oracle 11 database and a java development environment (using Eclipse)
Im using Eclipse 3.4, EclipseMe 1.7.9. Im trying to deploy/create package a simple project
When using Eclipse PDT with XDebug to debug a PHP web application, is there
I'm building a dynamic web application in Eclipse using Struts2 and OC4J 10.1.3.3.0. I'm
I'm using tomcat to run a web application. Without any projects added to my
Im using Eclipse with ADT plugin and Sequoia, and Im trying to deploy my
im using eclipse for python but i dont know for php.. how can i

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.