jspjsp-tags

How to hide the passing params in url using jsp page


<html>
<table border="1">
    <tr>

        <th>NAME</th>
        <th>Card No</th>
        <th>BANK</th>
        <th>PHONE NO</th>
        <th>PRIVATE KEY</th>
        <th>KEY</th>

    </tr></h3>
    <%
    try
    {
        Class.forName("com.mysql.jdbc.Driver");
        Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/frodo", "root","");
        Statement st = con.createStatement();
        String query = "select * from user ";
        ResultSet rs = st.executeQuery(query);
        while(rs.next())
        {
         %>   
         <tr>
             <td><%=rs.getString(1) %></td>
             <td><%=rs.getString(5) %></td>
             <td><%=rs.getString(6) %></td>
             <td><%=rs.getString(8) %></td>
             <td><%=rs.getString(10) %></td>
             <td>
                 <a href ='generatekey.jsp?d=<%=rs.getString(1)%>&d2=<%=rs.getString(10)%>'>Generate</a>

             </td>
             </tr> 
            <%  
        }
      }
      catch(Exception e)
        {
           out.println(e);
        }
      %>
</table> 

And now the another jsp page which using these values is .......
 <%
    String id = request.getParameter("d");
    String pk = request.getParameter("d2");
  %>

Solution

  • The response of Joseph in the comments is completely right.

    If you want to replace your <a href link... > that send a Get request, you have to replace it by a <form> + your destination url in the ‘action’ attribute and your parameters as hidden input field.
    Here is the direct link to such an example:
    https://stackoverflow.com/a/8398954/4444956
    And replace the action attribute value with “generatekey.jsp” and the ‘d’ and ‘d2’ as input hidden fields (with their corresponding ds... value).