Learning J2ee, got newbie question.  
Author Message
DaLoverhino





PostPosted: 2006-2-22 7:17:00 Top

java-programmer, Learning J2ee, got newbie question. 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.

 
trippy





PostPosted: 2006-2-22 11:40:00 Top

java-programmer >> Learning J2ee, got newbie question. In article <email***@***.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
> 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.*; //wrong

import javax.servlet.*;
import javax.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.
>
>

--
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"