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

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>









Related Tutorials/Questions & Answers:
how to get multiple hyperlink values from a table column to another jsp file?
Pls provide me jsp code to get values in drop down list from another table's field....
Advertisements
how to pass the mutiple values from <Ui:datagrid hyperlink - 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 column values from a excel file after attaching it - 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
how to get a values from processRecord - JSP-Servlet
Get values from JSP pages - JSP-Servlet
how to display values from database into table using jsp
use data from database table as hyperlink value - JSP-Servlet
retrieve multiple columns values from multiple csv files in java
how to use one form out of multiple form from one jsp to another jsp
How to Dragging and dropping HTML table row to another position(In Jsp) and save the new position (values) also in database(MySql)?
how to insert the bulk data into the data base from the table of jsp page to another jsp page
how to get values for same column name from two different tables in SQL
get value from multiple textbox in jsp
Adding a flex table in another flex table column
how to get a values from a multipart/form-data - JSP-Servlet
How to get the values from the Combo Box - JSP-Servlet
How to copy existing column along with data and column name into another existing table
Dragging and dropping HTML table row to another position(In Jsp) and save the new position (values) also in database
How to display all the Select values from the MySQL database table in where condition= In JSP?
How to get a values - JSP-Servlet
How to get a values - JSP-Servlet
How to forward the control from one jsp to another?
How to fetch entries/values from database to a jsp page one by one?
how to insert values from jsp into ms access
How to Display values from databse into table
how to pass an array from one jsp to another jsp - JSP-Servlet
how to upload multiple files in jsp and saving the path in database and the file in folder
Connecting to Database from a hyperlink in JSP - JSP-Servlet
Uploading Multiple Files Using Jsp
How to compare two tables, and insert values which r not in one table to another table?
How to insert and update all column values of database from jtable.
How to insert and update all column values of database from jtable.
How to add a column with checkboxes for each record in my table in JSP
inserting all the values in a html table column
How to insert and update all column values of database from jtable.
How to return multiple values from a method - Java Beginners
How to return multiple values from a method - Java Beginners
how to retrieve data from table with runtime values in sql?
Delete a Column from a Database Table
not able to get values from jsp file - JSP-Servlet
how to read the values for text and csv files and store those values into database in multiple rows..means one value for one row
program to enter values from one jsp page and then do calculation on some formula and that results is displayed in another jsp
How to insert data from a combobox and textbox values into DB using JSP?
how to get the values from dynamically generated textbox in java?

Ads