Servlet does not compile in Eclipse 3.1

I am a newbie.  I can produce the html version of hello world but when I try the servlet version I get the http 404 status error message.  I cannot locate a HelloWorldServlet.class in /class folder.  I also see "the serializable class HelloworldServlet does not declare a static final serialVersionUD field of long type.
I have Eclipse 3.1, tomcat 3.0.19 and JDK1.5.0_06.
latimercm4Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

bloodredsunCommented:
please post your web.xml and your sevlet code
0
latimercm4Author Commented:
HeloWorldServlet.java
package org.eclipse.Tom_sub;

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


public class HelloWorldServlet  extends HttpServlet{
      
      public void doGet(HttpServletRequest request,
                            HttpServletResponse response )
      throws IOException, ServletException {
            response.setContentType("text/html");
            PrintWriter out = response.getWriter();
            out.println("<html>");
            out.println("<body>");
            out.println("<h1>Hello World</html>");
            out.println("</body>");
            out.println("</html>");
      }
      
}

web.xml

<!DOCTYPE web-app
  PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
  "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>

  <servlet>
    <servlet-name>HelloServlet</servlet-name>
    <servlet-class>HelloWorldServlet</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>HelloServlet</servlet-name>
    <url-pattern>/hello</url-pattern>
  </servlet-mapping>

</web-app>

I'm believe it has something to do with how I have Eclipse set up.  I do not have a classpath variable defined.  I do not see any error anywhere.  I checked to see if there was a tomcat.log file.

0
fargoCommented:
I hope this is a typo
>>tomcat 3.0.19

moreover,
<servlet>
    <servlet-name>HelloServlet</servlet-name>
    <servlet-class>HelloWorldServlet</servlet-class>
  </servlet>

should be

<servlet>
    <servlet-name>HelloServlet</servlet-name>
    <servlet-class>org.eclipse.Tom_sub.HelloWorldServlet</servlet-class>
  </servlet>

fargo



0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

actonwangCommented:
>> I cannot locate a HelloWorldServlet.class in /class folder

     wouldn't it be /classes folder?
0
KuldeepchaturvediCommented:
>> I cannot locate a HelloWorldServlet.class in /class folder

It will be in web-inf/classes/org.eclipse.Tom_sub folder.
& also I hope you are typing http://localhost:8080/yourwebapp/hello to invoke your servlet & not
http://localhost:8080/yourwebapp/servlet/HelloWorldServlet
0
actonwangCommented:
>>It will be in web-inf/classes/org.eclipse.Tom_sub folder.
     
     should be web-inf/classes/org/eclipse/Tom_sub
0
latimercm4Author Commented:
I searched my drive and could not locate the file.  I searched Google and found something that indicated that I needed to have a file in order for the servlet to compile.  I modified my workspace and then the class compiled.  

I am going to run it in IE as http://localhost:8080/Tom1/HelloWorldServlet and see if it works...and then I will try the hello to see if one of them will work.
0
actonwangCommented:
set your compilation path to <web-root>/web-inf/classes or after compilation, copy them into web-inf/classes.
0
latimercm4Author Commented:
The "hello" works.  Is there a reason why I do not see the /WEB-INF/classes all of the time?

where do I modify the compilation path.  I was following a tutorial from javaboutique.  It indicated that if I modified the Tomcat/conf/web.xml using invoker and servlet mapping that I can run this using HelloWorldServlet class name.  On my workstation I get the status 404 message when I enter http://localhost:8080/Tom1/servlet/HelloWorldServlet (and then press enter).  Am I missing something here?  Or is Eclipse not properly set up?  Thank you for your help.
0
actonwangCommented:
<web root>/WEB-INF/classes needs to be created by you if you want it.

ok, you are using invoker, you have to give invoker a full class name: say you want to invoke class
package1.class1 then you have to do : http://.../Tom1/servlet/package1/class1

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
actonwangCommented:
Thanks for your rate.  You must've done a lot of tests. Hope you learned sth.

:)
0
latimercm4Author Commented:
Thank you.  I have become very frustrated.  Just trying to build a web application within Eclipse with struts without anything to help guide me has been very frustrating.  I've been using Java boutique as a guide...do you know of anything else I can use?  Thank you again for your help.  I still have not gotten all the kinks out but I am further along and I know that I will have more questions as I go along.

Have a wonderful day.
:)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JSP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.