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> 

http://www.w3schools.com/html/html_forms.asp


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo