Closed Thread
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-11-2009, 11:22 PM
Member
 
Join Date: Nov 2007
Posts: 3
Rep Power: 0
shuklajayb is on a distinguished road
Default HTTP 404 Error while running Servlet Application
Hi I'm getting HTTP 404 error code while running a Servlet Application.

folder structure is as follows

apache-tomcat-6.0.16
|--webapps
|--Ch01
|--WEB-INF
|--src
|--com
|--FirstServlet.java
|--classes
|--com
|FirstServlet.class


web.xml is as followos:

web.xml
=======

<servlet>
<servlet-name>FirstServlet</servlet-name>
<servlet-class>com.FirstServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>FirstServlet</servlet-name>
<url-pattern>/firstservlet</url-pattern>
</servlet-mapping>.

Please Help me in resolving this.

Thanks in Advance.
Bookmark Post in Technorati
  #2 (permalink)  
Old 04-27-2009, 04:50 PM
Member
 
Join Date: Feb 2009
Posts: 11
Rep Power: 0
devin is on a distinguished road
Default
I remember when I first started working with servlets and tomcat and I was getting 404 errors but I can't remember why.

I tried your servlet mapping and it worked on my version of tomcat, but I am using tomcat5.5. Not sure if something changed with the version you are using.

What is the content of the servlet?

Any errors when you reload the webapp?

Here is the content of the servlet I tried:

package com;

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

/**
* This is a test servlet
*
*/

public class FirstServlet extends HttpServlet {


@Override public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {

response.setContentType("text/html");

PrintWriter out = response.getWriter();

String docType = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " +
"Transitional//EN\">\n";

String title = "First Servlet";
out.println
(docType +
"<html>\n" +
"<head><title>" + title + "</title></head>\n" +
"<body BGCOLOR=\"#FDF5E6\">\n" +
"<h2>" + title + "</h2>\n" +
"Hey this is the first servlet!"+
"</body></html>");
}

@Override public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}


}
Bookmark Post in Technorati
  #3 (permalink)  
Old 05-06-2009, 02:10 PM
Member
 
Join Date: Apr 2009
Posts: 9
Rep Power: 0
saifuddin.merchant is on a distinguished road
Default
The servlet code looks correct. What is the link that you are hitting when you get the 404 error?

(The URL is case sensitive - just check if you are hitting the right URL)
Bookmark Post in Technorati
  #4 (permalink)  
Old 06-24-2009, 06:19 PM
Member
 
Join Date: Feb 2009
Posts: 11
Rep Power: 0
devin is on a distinguished road
Default
This could also be a security issue. Do any pages work for the Site?

Try setting security to no in your tomcat start up script:
TOMCAT5_SECURITY=no


You shouldn't do this for production systems but makes things easier when just trying to learn stuff.
Bookmark Post in Technorati
Closed Thread

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem in running jasper report in servlet khadaree Java Servlet 1 07-16-2009 10:35 AM
Run servlet in HTTP server jithan New To Java 25 10-16-2008 11:10 AM
HTTP Status 404 - Servlet action is not available---Error sireesha Web Frameworks 0 04-18-2008 08:25 PM
HTTP Status 404 - Servlet action is not available onceuponatime Java Servlet 1 12-11-2007 05:29 PM
Doubt in running the servlet ramachandran Java Servlet 0 10-25-2007 08:00 AM


All times are GMT +2. The time now is 04:33 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org