In try1.jsp file, the coding is
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Untitled Document</title>
</head>
<body>
<form action="insertData.jsp" method="post" name="frm1">
Please fill in the blanks and press submit button.
<br>
<br>
First Name: <input name="txtFirstName" type="text"><br><br>
Last Name: <input name="txtLastName" type="text"><br><br>
Email: <input name="txtEmail" type="text"><br>
<br>
<input name="btnSubmit" type="submit" value="Submit">
</form>
</body>
</html>
Then in insertData.jsp file, the coding is
<%@ page language = "java" import = "abc.def.*" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Untitled Document</title>
</head>
<body>
<%
//contoh Example = new contoh();
String strFirstName = request.getParameter("txtFirstName");
String strLastName = request.getParameter("txtLastName");
String strEmail = request.getParameter("txtEmail");
//Example.setFirstName(strFirstName);
//Example.setLastName(strLastName);
//Example.setEmail(strEmail);
%>
The first name is <%= //Example.getFirstName() %><br>
The last name is <%= //Example.getLastName() %><br>
The email is <%= //Example.getEmail() %><br>
<%
//Example.insertData();
//Example.setFirstName(a);
//Example.setLastName(b);
//Example.setEmail(c);
%>
ABC <%= //Example.getEmail() %>
</body>
</html>
Don't bother about all the object's method, it all refer to other .java file. But this is work to get form data. And of course this will not run, unless you can the your own .java file.
I hope this can help u...:)
Hello
|