Hello. I picked up a Beginner's J2ee book. I'm going through the
examples, but one of the examples I am stuck on. I cannot get past the
error message:
404 - Resource Not found.
I am running Tomcat, I believe 5.5.8. Here's the directory structure
that I have:
webapp/Ch05/
login.html
Login.java
Login.class
Here's the login.html:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Login</title>
</head>
<body>
<h1>Login</h1>
Please enter your username and password.
<form action="/Ch05/Login" method="POST">
<p><input type="text" name="username" length="40">
<p><input type="password" name="password" length="40">
<p><input type="submit" value="Submit">
</form>
</body>
</html>
My browser complains that Login resource is unavailable. Here's
Login.java, which is compiled and in the same directory.
package web;
import java.servlet.http.*;
import java.io.*;
public class Login extends HttpServlet {
public void doPost( HttpServletRequest request, HttpServletResponse
response)
{
String username = request.getParameter( "username");
try {
response.setContentType( "text/html");
PrintWriter writer = response.getWriter();
writer.println( "<html><body>");
writer,println( "Thank you, " + username +
". You are now logged into the system.");
writer.println( "</body></html>");
writer.close();
} catch( Exception e) {
e.printStackTrace();
}
}
}
Anyways, does anyone know what I'm doing wrong here? (I just typed the
example pretty quickly, so there might be typos, but the above compiles
without complaint.) Thanks.
info@hmdproducts.com - 22 Feb 2006 00:02 GMT
> Hello. I picked up a Beginner's J2ee book. I'm going through the
> examples, but one of the examples I am stuck on. I cannot get past the
> error message:
>
> 404 - Resource Not found.
Hope I didn't miss a detail. Check that the servlet is mapped
correctly in the web.xml file in the WEB-INF directory. It might need
something like:
<servlet-mapping>
<servlet-name>Login</servlet-name>
<url-pattern>/Ch05/Login</url-pattern>
</servlet-mapping>
HTH
-- Kyle
trippy - 22 Feb 2006 03:39 GMT
In article <1140563842.198568.224460@g43g2000cwa.googlegroups.com>,
DaLoverhino took the hamburger, threw it on the grill, and I said "Oh
wow"...
> Hello. I picked up a Beginner's J2ee book. I'm going through the
> examples, but one of the examples I am stuck on. I cannot get past the
[quoted text clipped - 36 lines]
>
> import java.servlet.http.*; //wrong
import javax.servlet.*;
import javax.servlet.http.*;
> import java.io.*;
>
[quoted text clipped - 20 lines]
> example pretty quickly, so there might be typos, but the above compiles
> without complaint.) Thanks.

Signature
trippy
mhm31x9 Smeeter#29 WSD#30
sTaRShInE_mOOnBeAm aT HoTmAil dOt CoM
NP: "I Am The Law" -- Anthrax
"Now, technology's getting better all the time and that's fine,
but most of the time all you need is a stick of gum, a pocketknife,
and a smile."
-- Robert Redford "Spy Game"
Paul Hamaker - 22 Feb 2006 08:38 GMT
Are you sure about the presence of Login.class where you suppose it to
be, because your source contains an error :
writer,println( "Thank you, " + us......
comma instead of dot
--------------------
Paul Hamaker, SEMM, teaching ICT since 1987
http://javalessons.com