how can i pass a value from jsp to servlet -
this part of jsp program.
<%@ page import="db.conn" %> <%@ page import="java.sql.*" %> <% try{ string id2=request.getparameter("id"); system.out.println(id2); %> <input type="hidden" name="id2" id="id2" value="<%=id2%>" > <% }catch(exception e) {system.err.println(e);} %> <form method="post" action="./transaction"> <button type="submit">pay now</button> </form> </span></div>
but when try id2 in servlet using statement:
string id=request.getparameter("id2");
i id=null
. how can value?
the input
tag element stores id2
has inside form element.
<%@ page import="db.conn" %> <%@ page import="java.sql.*" %> <form method="post" action="./transaction"> <% try{ string id2=request.getparameter("id"); system.out.println(id2); %> <input type="hidden" name="id2" id="id2" value="<%=id2%>" > <% }catch(exception e) {system.err.println(e);} %> <button type="submit">pay now</button> </form> </span></div>