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>

Ads









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 multiple values from a servlet to JSP?
How to carry multiple values from a Servlet to a JSP?
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 display values from database into table using jsp
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
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 use one form out of multiple form from one jsp to another jsp
get value from multiple textbox in jsp
How to get the values from the Combo Box - JSP-Servlet
retrieve multiple columns values from multiple csv files in java
How to get a values - JSP-Servlet
Adding a flex table in another flex table column
How to copy existing column along with data and column name into another existing table
How to display all the Select values from the MySQL database table in where condition= In JSP?
How to fetch entries/values from database to a jsp page one by one?
Dragging and dropping HTML table row to another position(In Jsp) and save the new position (values) also in database
How to forward the control from one jsp to another?
how to insert values from jsp into ms access
how to get the values from dynamically generated textbox in java?
how to upload multiple files in jsp and saving the path in database and the file in folder
How to Display values from databse into table
Get Column names using Metadata in jsp
how to get the values to dropdownlist from oracle database
How to add a column with checkboxes for each record in my table in JSP
How to compare two tables, and insert values which r not in one table to another table?
Uploading Multiple Files Using Jsp
How to save and get value from JSP
how to retrieve data from table with runtime values in sql?
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 insert data from a combobox and textbox values into DB using JSP?
How to insert and update all column values of database from jtable.
inserting all the values in a html table column
Delete a Column from a Database Table
how to count unique and duplicate values from one table in mysql?
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 retrieve array values from html form to jsp?
How to get table row contents into next jsp page
how to get data from database into dropdownlist in jsp
how to read values from excel sheet and compare with database using jsp
retrieving of data from one jsp to another jsp - JSP-Servlet
how to retreive values from MS Access Database based on the values entered in textbox values in jsp file
mysql select into table from another table example
how to get data from database into dropdownlist in jsp
how to get data from database into dropdownlist in jsp

Ads