This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Servlets and the fly likes HTTP 404 Error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "HTTP 404 Error" Watch "HTTP 404 Error" New topic
Author

HTTP 404 Error

Murat Balkan
Ranch Hand

Joined: Sep 10, 2002
Posts: 127
Hi,
I have the following web.xml file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!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>app1</servlet-name>
<servlet-class>MyApp1</servlet-class>
<init-param>
<param-name>username1</param-name>
<param-value>muratb</param-value>
</init-param>
<init-param>
<param-name>password1</param-name>
<param-value>muratb</param-value>
</init-param>
</servlet>
<servlet>
<servlet-name>testcm</servlet-name>
<servlet-class>QuestionAsk</servlet-class>
</servlet>
</web-app>

This application resides in /test directory under webapps.
When I call the first servlet with localhost/test/servlet/app1 it displays fine but localhost/test/servlet/testcm give HTTP Not Found error although it is declared in the web.xml file.
(I restarted the Tomcat Service)

What I am doing wrong?
Thank you
Murat
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
try adding

to your web.xml and restart Tomcat.


42
Murat Balkan
Ranch Hand

Joined: Sep 10, 2002
Posts: 127
Hi,
I tried it but didnt work. Both servletmapping and general convention (/context/servlet/servletname) does not work. First entry in the web xml file can be called but the second one returns an error 404.(first http 500 in the seconf refresh 404)
Http 500 root cause is
java.lang.IllegalAccessException: Class org.apache.catalina.core.StandardWrapper can not access a member of class app1 with modifiers ""
I think the problem is with app1 servlet. If so, whats the problem with the following servlet?
Heres the code of app1:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
class app1 extends HttpServlet
{
public void doGet(HttpServletRequest req,HttpServletResponse res) throws IOException,ServletException{

PrintWriter pw=res.getWriter();
pw.print("hello");
}
}

Thanks
Murat
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34


class app1 extends HttpServlet

It's not a public class.


[Jess in Action][AskingGoodQuestions]
Murat Balkan
Ranch Hand

Joined: Sep 10, 2002
Posts: 127
Thank you.I missed it. It works now.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HTTP 404 Error