?
Solved

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

Posted on 2005-03-12
9
Medium Priority
?
292 Views
Last Modified: 2010-04-01
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
0
Comment
Question by:akp007
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 29

Accepted Solution

by:
bloodredsun earned 400 total points
ID: 13524990
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
 

Author Comment

by:akp007
ID: 13525205
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
 
LVL 29

Expert Comment

by:bloodredsun
ID: 13525741
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:akp007
ID: 13526529
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
 
LVL 29

Expert Comment

by:bloodredsun
ID: 13528064
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
 
LVL 30

Expert Comment

by:Mayank S
ID: 13528154
Can you post the web.xml that you have created?
0
 

Author Comment

by:akp007
ID: 13530107
<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
 
LVL 30

Assisted Solution

by:Mayank S
Mayank S earned 100 total points
ID: 13532239
>> <servlet-class>HelloWWW</servlet-class>

You should specify the full-name of the servlet, along with the package.
0
 
LVL 29

Assisted Solution

by:bloodredsun
bloodredsun earned 400 total points
ID: 13533062
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An introduction to the wonderful sport of Scam Baiting.  Learn how to help fight scammers by beating them at their own game. This great pass time helps the world, while providing an endless source of entertainment. Enjoy!
The Summer 2017 Scholarship Winners have been announced!
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question