how to get multiple hyperlink values from a table column to another jsp file?

Ads
 

how to get multiple hyperlink values from a table column to another jsp file?

dear sir:

this is what i'm trying to do, i have 3 JSP files. first file named "index" asks the user to enter the itemid and and search for it. second file named "dbtable" will get the parameter from "index" and search for the user string in the database, as a result a table will come up with 3 columns itemid, itemname, and description. now my itemid column is all in hyperlinks, so if the user click on one of these hyperlinks the third file named "table2" should show the specific details from that hyperlink which was clicked. there are 3 columns in "table2" which are itemid, subinventoryid, and transactionquantity, please note that "dbtable" and "table2" have relation in itemid. please show me how can i copy the hyperlink value to that third jsp file "table2", or if you have another way in JSP please share. these are my codes:

***index.jsp***

<html>

<head>  

<title>searching DB</title>

</head>

<body>

<ht>TST1 DB</h1>

<form action="dbtable.jsp" method="post" >

<p> Please Enter Item ID LIKE(%)</p>

<input type="text" name="id"/>

<input type="submit" name="submit" value="Search"/>

</form>

</body>

</html>


***dbtable.jsp***

<html>

<head>

<title>DataBase</title>

</head>

<body>

<%
String URL = "";

Class.forName("oracle.jdbc.OracleDriver").newInstance();

conn = DriverManager.getConnection(URL, "root", "root");

stmt = conn.createStatement();

String id = request.getParameter("id");

String QueryString = "select * from items where organization_id = 84 and
"+"item_id LIKE '"+id+"'";

rs = stmt.executeQuery(QueryString);

%>

<INPUT TYPE="button" VALUE="Back" onClick="history.go(-1);return true;"/>

<table  border="1" style="table-layout: fixed" >

<th>Item ID</th>    
<th>Item Name</th>
<th>Description</th>

<%
while (rs.next()) {
%>

<tr>

<td><%=rs.getInt("item_id")%></a> </td>

<TD><%=rs.getString("item_name")%></TD>

<TD><%=rs.getString("description")%></TD>

</tr>

<%   }    %>
<%


rs.close();
stmt.close();
conn.close();
%>

</table>    

</center>
</body>
</html>



***table2.jsp***

<html>
    <head>
    <title>DataBase2</title>

    </head>

<body>

<%              
        String URL = "";

        Class.forName("oracle.jdbc.OracleDriver").newInstance();

        conn = DriverManager.getConnection(URL, "root", "root");

        stmt = conn.createStatement();



        String QueryString = "select * from mtl_onhand_quantities"
        + " where item_id = ''"

    rs = stmt.executeQuery(QueryString);

%>

<center>

<table  border="1" style="table-layout: fixed" >

    <th>item code</th>
    <th>subinventory code</th>
    <th>onhand</th>       

    <%
    if  (rs.next()) {
    %>

    <tr>

       <TD><%=rs.getInt("item_id")%>"/> </TD>
       <TD><%=rs.getString("subinventory_code")%> </TD>
       <TD><%=rs.getInt("transaction_quantity")%> </TD>


    </tr>          

    <%   }    %>
    <%
    // close all the connections.
    rs.close();
    stmt.close();
    conn.close();
  %>

  </table>    

</center>
</body>
</html>

thank you

View Answers

June 2, 2011 at 3:43 PM

1)search.jsp:

<html>
<form method="post" action="dbtable.jsp">
Enter id: <input type="text" name="id">
<input type="submit" value="Search">
</form>
</html>

2)dbtable.jsp:

<%@page import="java.sql.*"%>
<html>
<table border="1">
<%
try{
String v=request.getParameter("id");
int id=Integer.parseInt(v);
Class.forName("com.mysql.jdbc.Driver").newInstance();  
 Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");  
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("Select * from items where itemid="+id+"");
while(rs.next()){
    %>
<tr><td><a href="table2.jsp?id=<%=rs.getString("itemid")%>"><%=rs.getString("itemid")%></a></td><td><%=rs.getString("item")%></td><td><%=rs.getString("description")%></td></tr>
<%
}
}
catch(Exception e){
    System.out.println(e);
}
%>
</table>
</html>

3)table2.jsp:

<%@page import="java.sql.*"%>
<html>
<table border="1">
<%
String v=request.getParameter("id");
int id=Integer.parseInt(v);
Class.forName("com.mysql.jdbc.Driver").newInstance();  
 Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");  
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("Select * from subinventory where itemid="+id+"");
while(rs.next()){
    %>
<tr><td><%=rs.getInt("itemid")%></td><td><%=rs.getInt("subinventoryid")%></td><td><%=rs.getInt("quantity")%></td></tr>
<%
}
%>
</table>
</html>

Ads









Related Tutorials/Questions & Answers:
how to get multiple hyperlink values from a table column to another jsp file?
how to pass the mutiple values from <Ui:datagrid hyperlink - JSP-Servlet
Advertisements
Pls provide me jsp code to get values in drop down list from another table's field....
how to get a column values from a excel file after attaching it - JSP-Servlet
How to pass multiple values from a servlet to JSP?
How to carry multiple values from a Servlet to a JSP?
How to Sort Column values of a jsp table - JSP-Servlet
how to get a values from processRecord - JSP-Servlet
How to update table column from the values of Arraylist in java
how to pass the mutiple values from <Ui:datagrid hyperlink - JSP-Servlet
Get values from JSP pages - JSP-Servlet
how to get values for same column name from two different tables in SQL
how to display values from database into table using jsp
How to Dragging and dropping HTML table row to another position(In Jsp) and save the new position (values) also in database(MySql)?
retrieve multiple columns values from multiple csv files in java
how to insert the bulk data into the data base from the table of jsp page to another jsp page
use data from database table as hyperlink value - JSP-Servlet
how to get a values from a multipart/form-data - JSP-Servlet
how to use one form out of multiple form from one jsp to another jsp
How to get the values from the Combo Box - JSP-Servlet
get value from multiple textbox in jsp
How to get a values - JSP-Servlet
Adding a flex table in another flex table column
How to get a values - JSP-Servlet
How to copy existing column along with data and column name into another existing table
how to upload multiple files in jsp and saving the path in database and the file in folder
How to display all the Select values from the MySQL database table in where condition= In JSP?
How to Display values from databse into table
how to get the values from dynamically generated textbox in java?
how to get the values to dropdownlist from oracle database
Dragging and dropping HTML table row to another position(In Jsp) and save the new position (values) also in database

Ads