简体   繁体   中英

How to Fetch data by clicking image

I have the following code in edit.jsp

<%
while (rs.next()) 
{
%>
<tr>
<TD><%=rs.getString(1)%></TD>  //for text box name
<TD><%=rs.getString(2)%></TD>  //for text box address
<TD><%=rs.getString(3)%></TD>  //for text box origin 
<td><a href="create.jsp"> <img src="images/editdetail.png"></a></td>
</tr>

while clicking the image/editdetail.png i am redirecting the page to create.jsp, where i have three text boxes("name", "address" and "origin"). how to get the getString value also getting displayed in the text box when i click the png image, so that i can edit the details.

You could pass this as params as TJ mentioned. But if you think its kinda insecure, because the details are present in the URL, you could save the details as an object in the session. using session.setAttribute() . In the create.jsp, read the object against the key and populate the text boxes accordingly.

A usecase similar to your's is illustrated in this example : http://www.jsptut.com/sessions.jsp

I believe, the create.jsp will submit the detials to another JSP. say... submit_details.jsp in submit_details.jsp, after processing the details, do remember to remove the attribute from the session.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM