Someone point me to the right direction..
Hi all,
I am learning jsp by doing some simple jsp pages. The codes are below..
my index.jsp
Code :
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<form action="howdatapass.jsp" method="get" name="test">
<td class="bb" nowrap align=right><font color=#ff0000>*</font> Full Name 1:</td>
<td><input type=text id="f1" name="fullName" size=20></td>
<td class="bb" nowrap align=right><font color=#ff0000>*</font> IC Number:</td>
<td><input type=text name="icNo" size=20></td>
<input type = "submit" name = "Submit" value = "Continue">
</form>
</body>
</html>
my howdatapass.jsp
Code :
<jsp:useBean id = "test" class = "newpackage.flow" scope = "session"></jsp:useBean>
<jsp:setProperty name = "test" property = "*" />
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<p>You entered the following data</p>
<p>get full name: <%= test.getFullName() %></p>
<p>get IC: <%= test.getIcNo() %></p>
</body>
</html>
and my java code.. flow.java
Code :
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package newpackage;
/**
*
* @author admin
*/
public class flow {
private String fullName = "";
private String icNo = "";
public String getFullName() {
return this.fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public String getIcNo() {
return this.icNo;
}
public void setIcNo(String icNo) {
this.icNo = icNo;
}
}
So when I key in data in index.jsp, it does displayed it on howdatapass.jsp..
But the problem is, when I actually create another example.jsp file and copy code the same code like in hawdatapass.jsp and run this example.jsp.. It still displayed the values that I key in earlier in index.jsp. Seems to me the flow.java still keep the values that he get from index.jsp earlier. So how do I reset the value back to null when I call this flow.java in another jsp page?
p/s: sry for my bad english..