Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HTTP Status 404 - /onjava/servlet/com.onjava.login

 
roy ramos
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there i'm new in java and i was trying to follow some examples that i got also from internet it's how to create login form,
the login.jsp file is working but as soon as i click the submit button it gives me the error

HTTP Status 404 - /onjava/servlet/com.onjava.login

i'm wondering why there is additional directory being called"servlet"

this is how i created the folder in tomcat 6.0


webapps
|
onjava
|
WEB-INF
|
web.xml
lib
classes
|
com
|
onjava
|
login.class

this is the login.jsp file

<html>
<head>
<title>OnJava Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#66CCFF" onLoad="document.loginForm.username.focus()">

<table width="500" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<table width="500" border="0" cellspacing="0" cellpadding="0">
<form name="loginForm" method="post" action="servlet/com.onjava.login">
<tr>
<td width="401"><div align="right">User Name: </div></td>
<td width="399"><input type="text" name="username"></td>
</tr>
<tr>
<td width="401"><div align="right">Password: </div></td>
<td width="399"><input type="password" name="password"></td>
</tr>
<tr>
<td width="401"> </td>
<td width="399"><br><input type="Submit" name="Submit"></td>
</tr>
</form>
</table>
</td>
</tr>
</table>
</body>
</html

this it web.xml

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">

<display-name>Login Application</display-name>
<description>
Login Application
</description>

<servlet>
<servlet-name>login</servlet-name>
<servlet-class>com.onjava.login</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>login</servlet-name>
<url-pattern>/login</url-pattern>
</servlet-mapping>

</web-app>

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic