Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2006

Tip: Looking for answers? Try searching our database.

Learning J2ee,  got newbie question.

Thread view: 
DaLoverhino - 21 Feb 2006 23:17 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.

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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.