0

I am using MYSQL database and for programming I am using JSP. Now I am extracting a value from database in my result.jsp page using this code:

String pid="";
while(resultSet.next()
{
<form action="report.jsp">
<%=resultSet.getString("patient_id") %>
<% pid=resultSet.getString("patient_id"); %>
<% request.setAttribute("acId", "pid"); %> 
<input type="submit"></input>
</form>
}

pid is a variable used to store the value of Patient ID.

I want to transfer that value to another jsp page which is report.jsp

I am retrieving the value in repost.jsp as follows:

<%
String paid = (String)(request.getAttribute("acId"));
%>

Then I have to store this value in database. But no value is being tranferred and stored in the variable paid.

I have also seen this question but got no help.

Please ignore any errors as I am new to MYSQL and JSP.

Piyush Agarwal
  • 102
  • 1
  • 14

1 Answers1

0

Instead of

<% request.setAttribute("acId", "pid"); %> 

Use

<input id="acId" name="acId" type="hidden" value="<%= pid %>" />

So that when submitting, every form input element will be transferred to the report.jsp.

And btw: you 're using while(resultSet.next())...may better to use if(resultSet.next())

Rey333
  • 350
  • 2
  • 12