I'm trying to enter a name (username and password) in a JSP file and try to get that in a java class. The java class should read the username and print it out in the console.
JSP Page:
<html>
<body>
<form method="post" action="../adAuth/check/Validate">
<table>
<tr>
<td>Username:</td> <td><input type="text" name="username"></td>
</tr>
<tr>
<td> </td><td><input type="submit"></td>
</tr>
</table>
</form>
</body>
</html>
Java Code
package check;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Validate extends HttpServlet{
public void doPost(HttpServletRequest request, HttpServletResponse response)
{
String name= request.getParameter("username");
System.out.println(name);
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
{
doPost(request, response);
}
}
When, I press the submit button, It is unable to find the java file (The webpage cannot be found - error appears) and hence nothing gets printed in the console. Any suggestions on what I'm doing wrong and how to rectify it ?
Edited by: Ramzey on Sep 8, 2010 11:24 AM