passing a value in anchor tag to another jsp

17,985
div class="bar">
 <div class="menulink"><a href="index.html">Home</a></div>
            <div class="menulink"><a href="savingsAccount.jsp?username=<%=request.getParameter("uname")%>">Savings</a></div>
            <div class="menulink"><a href="#">FAQ</a></div>
            <div class="menulink"><a href="#">Help</a></div>
 </div>
</div>

And in the savingsAccount.jsp you can get this parameter using:

String uname = request.getParameter("username");
Share:
17,985
APPU cool
Author by

APPU cool

Updated on June 04, 2022

Comments

  • APPU cool
    APPU cool almost 2 years

    i have a jsp in which ther are some anchor tags for redircting to other html pages or jsps.. but one particular jsp, i wanna send a parameter ie.. username to the jsp..from this jsp.. how can i do it in a simple way.. or any way possible i want to send uname parameter that i am obtaining from scriptlet to the jsp savingsAccount.jsp when it is clicked on

    div class="bar">
     <div class="menulink"><a href="index.html">Home</a></div>
                <div class="menulink"><a href="savingsAccount.jsp">Savings</a></div>
                <div class="menulink"><a href="#">FAQ</a></div>
                <div class="menulink"><a href="#">Help</a></div>
                </div>
    
        <% 
    
        Class.forName("com.mysql.jdbc.Driver");
        Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/mutualfund", "root", "");
    
    
        Statement statement = connection.createStatement();
        String uname = request.getParameter("uname");
        out.println(uname);
        out.println("Editing "+uname);
        String query="SELECT * FROM `cust_info_table` WHERE `cust_id`=\""+uname +"\"";
        ResultSet resultset =  statement.executeQuery(query) ;
    
  • APPU cool
    APPU cool almost 11 years
    its going to savingsaccount true... but unfortunately username is taking null i mean request.getParameter("username") ; is giving null value!!! meaning thevalue is not taken
  • MaVRoSCy
    MaVRoSCy almost 11 years
    its taking null because this request.getParameter("uname") is null most probably. Check it out.