I have tried to search for the same problems but those do not give the result that I need. I have an input box in my .jsp file, which need to get an array data from the user. After the user push the Result button, the array data given by the user is still stored in the input box. So I have this code:
<%@ page import="RunPKmodelVII.Function"%>
<%@ page import="com.mathworks.toolbox.javabuilder.MWException"%>
<%@ taglib prefix="wf" uri="http://www.mathworks.com/builderja/webfigures.tld"%>
<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My Second Project</title> <
<link rel="Stylesheet" type="text/css" media=all href="./StyleSheet.css" />
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
<%
String tf_simStr = request.getParameter("tf_sim");
int tf_sim = 10;
if (tf_simStr != null && tf_simStr.length() > 0) {
tf_sim = Integer.parseInt(tf_simStr);
}
String y0Str = request.getParameter("y0");
String y0 = "1 0 0 0";
if (y0Str != null && y0Str.length() > 0) {
y0 = Arrays.toString(y0Str);
}
%>
</head>
<body>
<center>
<h1>Development of Java Interface</h1>
<!--
<form action="http://localhost:8080/SecondServlet">
-->
<form action="SecondServlet">
<b>PK Model Calculation<br> <br></b>
<table align="center" border="1" bgcolor="#F5DEDE">
<thead>
<tbody>
<tr align="center">
<td>Time<br> <input type="text" name="tf_sim"
id="tf_sim" value="<%=tf_sim%>" /></td>
</tr>
<tr align="center">
<td>Initial Condition<br> <input type="text" name="y0"
id="y0" value="<%=y0%>" /></td>
</tr>
</tbody>
<tbody>
<tr>
<td colspan="10"> </td>
</tr>
<tr>
<td align="center" colspan="10"><input type="submit"
value="Result" name="DoPLot" id="DoPLot" /></td>
</tr>
</tbody>
</table>
<br> <br>
<div>
<wf:web-figure root="WebFigures" name="Project_Figure"
scope="session" />
</div>
</form>
</center>
</body>
</html>
The problem is, only the 1st view will give the value '1 0 0 0'. After the user change this value (eg. 2 1 0 1), the numbers in the input box will change to 'null'. I really hope someone could help. Thanks in advance!
UPDATE: I have put in more related codes for everybody's reference. If you can see, the first string (tf_sim) does not have any problem with storing the user input value in the input text box after pushing the Result button. But the value for the second string (y0) could not be stored as needed. Hope you may help. Thanks!