Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Send Data From JSP to java file

843840Sep 8 2010 — edited Dec 10 2010
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>&nbsp;</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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 7 2011
Added on Sep 8 2010
2 comments
741 views