Trying to figure out why I can't seem to fix the Status 404 error with Tomcat. I can see the other servlet samples working in the Tomcat Sample website. The webserver appears to be working, but when I try to run my servlet from the index.html page in my greeting directory, it just doesn't work. Any help would be appreciated. I put all of the $path and other info below as well as the html, java and web.xml info below.
*** I did compile the java file in the right directory I believe with the following command while in the $TOMCAT_HOME/webapps/greeting/src directory..:
javac -classpath $CLASSPATH/servlet-api.jar -d ./WEB-INF/classes *.java
Name of servlet I'm trying to call after hitting the submit button on the index.html page..:
http://localhost:8080/greeting/servlet/GreetingServlet
echo $PATH
/usr/lib/jvm/java-6-sun/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/var/lib/tomcat6/lib:/usr/share/tomcat6
echo $JAVA_HOME..:
/usr/lib/jvm/java-6-sun
echo $TOMCAT_HOME..:
/var/lib/tomcat6
echo $CLASSPATH..:
/var/lib/tomcat6/lib
echo $CATALINA_HOME..:
/usr/share/tomcat6
Here is the index.html..:
<HTML>
<HEAD>
<TITLE>ProJava Registration</TITLE>
</HEAD>
<BODY>
<H1>Welcome</H1>
<FORM ACTION='/greeting/servlet/GreetingServlet' METHOD='POST'>
<P>Your Name <INPUT TYPE='text' SIZE='40' NAME='name'></P>
<P>Your Email <INPUT TYPE='text' SIZE='40' NAME='email'>
<INPUT TYPE='submit' VALUE='Submit'></P>
</FORM>
</BODY>
</HTML>
Ok Here is my web.xml..:
<?xml version='1.0' encoding='ISO-8859-1'?>
<!DOCTYPE web-app
PUBLIC '-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN'
'http://java.sun.com/j2ee/dtds/web-app_2.2.dtd'>
<web-app>
<servlet>
<!-- Servlet alias -->
<servlet-name>GreetingServlet</servlet-name>
<!-- Fully qualified Servlet class -->
<servlet-class>GreetingServlet</servlet-class>
</servlet>
</web-app>
Here is the GreetingServlet.java file..:
// Import Servlet packages
import javax.servlet.*;
import javax.servlet.http.*;
// Import other Java packages
import java.io.*;
import java.util.*;
public class GreetingServlet extends HttpServlet {
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException,
IOException {
// Get parameters from the request.
String name = request.getParameter('name');
String email = request.getParameter('email');
// Compute a greeting message
String message = null;
GregorianCalendar calendar = new GregorianCalendar();
if(calendar.get(Calendar.AM_PM) Calendar.AM) {
message = 'Good Morning';
}
else {
message = 'Good Afternoon';
}
// Set MIME type for the response
response.setContentType('text/html');
// Obtain a print writer object
PrintWriter out = response.getWriter();
// Write the content
out.println('<HTML>');
out.println('<BODY>');
out.println('<P>' + message + ', ' + name + '</P>');
out.println('<P> Thanks for registering your email (' + email +
') with us.</P>');
out.println('<P> - The Pro Java Team. </P>');
out.println('</BODY>');
out.println('</HTML>');
out.close();
}
}
Tomcat Status 404 Resource Not Available
Tomcat is designed to serve static files via the. Re: HTTP status 404 Hi Chris Thanks for the reply Didn't you ask this same question the day before. Tomcat tomcat6 http-status-code-404. Improve this question. Adobe illustrator cc download for mac. Follow asked Nov 23 '10 at 14:29. Canon pixma mx492 driver download for mac. 1,303 5 5 gold badges 23 23 silver badges 36 36 bronze. I could run Tomcat 7 from the command line and see the Tomcat page at localhost:8080, but using the IDE to start Tomcat I could not. Rather, when starting Tomcat using the IDE I got the HTTP 404. The solution was in setting the 'Server Location' of Tomcat within the IDE, as described here. 'The requested resource is not available.' Hi all, i'm a newbie with tomcat. I've istalled tomcat on my windows xp of my work station and all is going right. Tomcat › Tomcat - User. Search everywhere only in this topic. HTTP Status 404. HTTP status 404 for a servlet using Tomcat and IntelliJ. Yac678 asked on 2010-04-10. Editors IDEs; Apache Web Server; JSP; 8 Comments. Last Modified: 2013-12-14. I am using IntelliJ 8.1 and a simple Web application which has a login JSP.
