We help IT Professionals succeed at work.
Get Started

Servlet is calling the wrong class

Last Modified: 2013-12-15
I have attached my project, my problem is my project is calling my servlet from the wrong path, Project/html/AddData, for example this however is wrong.

I was intially calling my servlet in the default package without a web.xml file, the form gave the address /Project/servlet/AddData. This worked.

I then changed it to the package to com.project.controller, it then stopped working. I assumed this was due to the lack of a deployment descriptor "web.xml" file. I added this file, changed the form address to "AddData". This still isnt working, I am missing a step or have I made a mistake somewhere. I attached the relevant files
<TITLE>Registration Form</TITLE>
<link rel="stylesheet" type="text/css" href="/Project/html/Style.css"/>


<H3>Choose and Insert GPSData:</H3>

<SELECT NAME = "gpsdata">
  <BR><INPUT TYPE="submit" value="Submit Form"> 
  <INPUT TYPE="reset" value="Clear Form">

Open in new window

<?xml version = '1.0'?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, 
Inc.//DTD Web Application 2.2//EN" 
   <display-name>Deployment Descriptor</display-name>
   <description>Servlet Examples for EE557</description>

Open in new window

package com.project.controller;
import java.io.*;
import java.util.Vector;
import javax.servlet.*;
import javax.servlet.http.*;

public class AddData extends HttpServlet {
	private static final long serialVersionUID = 1L;
	DBManager a = new DBManager();

	public void doPost(HttpServletRequest req, HttpServletResponse res)
	throws ServletException, IOException 
		String NMEAData = req.getParameter("gpsdata");
		GPSData b = a.ParseData(NMEAData);


Open in new window

Watch Question
This problem has been solved!
Unlock 1 Answer and 9 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE