Servlet Not running. Getting the message HTTP Status 404..

Dear Experts-

Before I post this question, I have read threads related to this issue. I still face this problem.

This is related to servlets.Please guide me. I don't know where it was going wrong. I could able run my JSP with out any issues.

1. I am getting following message

MyURL : http://localhost:8080/MyApplication/servlet/coreservlets.HelloWWW

HTTP Status 404 - /MyApplication/servlet/coreservlets.HelloWWW

type Status report

message /MyApplication/servlet/coreservlets.HelloWWW

description The requested resource (/MyApplication/servlet/coreservlets.HelloWWW) is not available.

My folder structure:

C:\Program Files\Apache Group\Tomcat 4.1\webapps\MyApplication\WEB-INF\classes\coreservlets

classpath :

C:\Program Files\Apache Group\Tomcat 4.1\webapps\MyApplication\WEB-INF\classes;
C:\Program Files\Apache Group\Tomcat 4.1\common\lib\servlet.jar

Thank you
akp007Asked:
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:
What does your web.xml look like? Have you mapped this servlet in the web.xml? if you haven't, you will need to map the servlet similar to this example http://www.murach.com/books/jsps/questions.htm
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
akp007Author Commented:
Wow! Great. I removed the commnet as mentioned in the url you mentioned , My code is working. But I have a question.
1.   Right now I don't have web.xml under C:\Program Files\Apache Group\Tomcat 4.1\webapps\MyApplication\WEB-INF\.
2.   Still my code is working by removing the comment from  "  <!-- The mapping for the invoker servlet -->" in
      Tomcat  4.1\conf\web.xml.
3.  But do we need to have web.xml under the current apllication directory. Because I have seen one under examples directory

Thanks

0
bloodredsunCommented:
1./Because you are accessing the servlet directly through the invoker servlet as you have said! If you moved your webapp to another server it would not work. That is why you need to create a web.xml under the webapp and you can call it a different name
2./as above
3./as above

Glad you have helped
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

akp007Author Commented:
What I did was I created a web.xml  under C:\Program Files\Apache Group\Tomcat 4.1\webapps\MyApplication\WEB-INF, then my JSP are not working. Any suggestions.

Thanks
0
bloodredsunCommented:
Probably because your web.xml is faultly. It can't be a copy of the one in tomcat/conf but you need to create one just for your web app.
0
Mayank SAssociate Director - Product EngineeringCommented:
Can you post the web.xml that you have created?
0
akp007Author Commented:
<web-app>
    <display-name>Tomcat Examples</display-name>
    <description>
      My Applications
    </description>

    <!-- Define filter mappings for the defined filters -->
    <filter-mapping>
        <filter-name>Servlet Mapped Filter</filter-name>
      <servlet-name>invoker</servlet-name>
    </filter-mapping>
    <filter-mapping>
        <filter-name>Path Mapped Filter</filter-name>
      <url-pattern>/MyApplication/servlet/*</url-pattern>
    </filter-mapping>
      
    <servlet>
        <servlet-name>HelloWWW</servlet-name>
        <servlet-class>HelloWWW</servlet-class>
    </servlet>
      
    <servlet-mapping>
        <servlet-name>HelloWWW</servlet-name>
        <url-pattern>/HelloWWW</url-pattern>
    </servlet-mapping>
</web-app>

Thank you
0
Mayank SAssociate Director - Product EngineeringCommented:
>> <servlet-class>HelloWWW</servlet-class>

You should specify the full-name of the servlet, along with the package.
0
bloodredsunCommented:
Assumming that your servlet code is in a class called HelloWWW.class which is in the directory
C:\Program Files\Apache Group\Tomcat 4.1\webapps\MyApplication\WEB-INF\classes\coreservlets
and also has the package declaration of coreservlets at the top of the code e.g.

package coreservlets;

It should be as mayankeagle says,

web.xml
-----------

<?xml version="1.0" encoding="UTF-8"?>
<!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>
    <display-name>My Application</display-name>
    <description>
      My Applications
    </description>
    <servlet>
        <servlet-name>HelloWWW</servlet-name><!-- logical name for this servlet in the web.xml-->
        <servlet-class>coreservlets.HelloWWW</servlet-class><!--specify the fullname inc. package-->
    </servlet>
     
    <servlet-mapping>
        <servlet-name>HelloWWW</servlet-name><!-- logical name again from above-->
        <url-pattern>/HelloWWW.do</url-pattern><!-- the url we are mapping this servlet to-->
    </servlet-mapping>
</web-app>

and should be accessed by going to http://localhost:8080/MyApplication/HelloWWW.do

The above example is taken from a tomcat 4 webapp, you may need to alter the dtd declaration at the top if you are using tomcat 5.
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.