Home Answers Viewqa JSP-Servlet Get specific item details by clicking on hyperlink

 
 


gautamshetkar
Get specific item details by clicking on hyperlink
2 Answer(s)      2 years and a month ago
Posted in : JSP-Servlet

sir, I am developing a shopping site, following is my problem definition: I have a search item button, if I click on that button it lists all items with item name and corresponding image with a hyperlink on it from the database to a jsp page.

-If I click on the image or item name I should get total datails from the database of that particular item which I clicked. How should I perform this? Thanks in advance

View Answers

April 8, 2011 at 5:31 PM


1)listitem.jsp:

<%@ page import="java.sql.*,java.io.*,java.util.*" %> 
<HTML>
 <table border="1">
 <tr><th>Items</th><th>Image</th></tr>
   <%
  try{      
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");
    Statement stmt=con.createStatement();
    String strQuery = "select * from items";
    ResultSet rs = stmt.executeQuery(strQuery);
    while(rs.next()){
       %>
      <tr>
      <td><%=rs.getString("item")%></td>
      <td>
      <a href="info.jsp?imgid=<%=rs.getInt(1)%>">
      <img src="items.jsp?imgid=<%=rs.getInt(1)%>" width="50" height="50">
</a></td>
      </tr>
      <%
    }
    rs.close();
    con.close();
    stmt.close();
  }
  catch(Exception e)
  {
    e.getMessage();
  }
  %>
 </table>
</HTML>

2)items.jsp:

<%@ page import="java.sql.*,java.io.*,java.util.*" %> 
<%
  int id =  Integer.parseInt(request.getParameter("imgid"));
  try{      
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");      
    Statement st=con.createStatement();
    String strQuery = "select image from items where id="+id;
    ResultSet rs = st.executeQuery(strQuery);

    String imgLen="";
    if(rs.next()){
      imgLen = rs.getString(1);
       }  
    rs = st.executeQuery(strQuery);
    if(rs.next()){
      int len = imgLen.length();
      byte [] rb = new byte[len];
      InputStream readImg = rs.getBinaryStream(1);
      int index=readImg.read(rb, 0, len);  
      st.close();
      response.reset();
      response.getOutputStream().write(rb,0,len); 
      response.getOutputStream().flush();        
    }
  }
  catch (Exception e){
    e.printStackTrace();
  }
%>

3)info.jsp:

 <%@ page import="java.sql.*,java.io.*,java.util.*" %> 
 <table>
 <%
 int id =  Integer.parseInt(request.getParameter("imgid"));
 try{      
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");      
    Statement st=con.createStatement();
    String strQuery = "select * from items where id="+id;
    ResultSet rs = st.executeQuery(strQuery);
    if(rs.next()){

%>
<tr><td>Item:</td><td><input type="text" value="<%=rs.getString("item")%>"></td></tr>
<tr><td>Price:</td><td><input type="text" value="<%=rs.getDouble("price")%>"></td></tr>
<tr><td>Information:</td><td><textarea cols="15" rows="5"><%=rs.getString("information")%>

April 8, 2011 at 5:32 PM


Modify info.jsp:

<%@ page import="java.sql.*,java.io.*,java.util.*" %> 
 <table>
 <%
 int id =  Integer.parseInt(request.getParameter("imgid"));
 try{      
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");      
    Statement st=con.createStatement();
    String strQuery = "select * from items where id="+id;
    ResultSet rs = st.executeQuery(strQuery);
    if(rs.next()){

%>
<tr><td>Item:</td><td><input type="text" value="<%=rs.getString("item")%>"></td></tr>
<tr><td>Price:</td><td><input type="text" value="<%=rs.getDouble("price")%>"></td></tr>
<tr><td>Information:</td><td><textarea cols="15" rows="5"><%=rs.getString("information")%></textarea></td></tr>
<%
    }
 }
 catch(Exception e){
     System.out.println(e);
 }
 %>
</table>









Related Pages:
Get specific item details by clicking on hyperlink
Get specific item details by clicking on hyperlink  sir, I am developing a shopping site, following is my problem definition: I have a search item... on the image or item name I should get total datails from the database
how to get multiple hyperlink values from a table column to another jsp file?
show the specific details from that hyperlink which was clicked. there are 3...how to get multiple hyperlink values from a table column to another jsp file... file named "dbtable" will get the parameter from "index" and search
Hyperlink
Hyperlink  The excel file is not opening in read only mode ,it is editable,actually i need to open it in read only mode by clicking on link.please help me
Java JComboBox Get Selected Item Value
Java JComboBox Get Selected Item Value In this section we will discuss about how to get the selected item value form JComboBox. javax.swing.JComboBox... example into which I shall get the combo box selected item value and stored
storing details in database on clicking submit button - JSP-Servlet
storing details in database on clicking submit button  I am using JSP... 'Name' and 'ID'.I want to store the details of these two fields in the MYSQL database on clicking submit button. I am unable to do this.Can u tell me how to code
Retrieving specific data from excel
Retrieving specific data from excel  Hello everyone, i have written... contain heading for each row written in bold and the student details such as Sl.No, Name, Roll Number followed by it. I want only those students details
Write a program to get student details and store in a database
Write a program to get student details and store in a database  Write a program to get student details and store in a database
Hide hyperlink using jQuery
Hide hyperlink using jQuery In this tutorial, we will discuss about how to hide hyperlink after clicking it using jQuery. In the below example , a hyperlink...(); The given below code is responsible for hiding link after clicking
hyperlink
hyperlink  I have a .xls file and i want the code to open this .xls file in read only mode when i click on a hyperlink,it should not not be editable,please send me the code
Set Date Parameter to get specific value
Set Date Parameter to get specific value  How to set the date parameter or fetch a specific data records based on date? For example fetching the two or three months old records
get details of employee after enter the emp_id
get details of employee after enter the emp_id  how to get employee details after entered the emp_id from database after that we have three more option add new,modify and delet employee   Please visit the following
get details of employee after enter the emp_id
get details of employee after enter the emp_id  how to get employee details after entered the emp_id from database after that we have three more option add new,modify and delet employee   Please visit the following
how to get the details of username&password of mysql - JDBC
how to get the details of username&password of mysql  Hi friends, i installed mysql 5.5 on my system successfully,but the thing is i forgotten the username and password .please tell me how to get those details . Thanks
use data from database as hyperlink and pass the data in the hyperlink
use data from database as hyperlink and pass the data in the hyperlink  Hi Friends, I am using the data from database as hyperlink and pass the data as a parameter in the hyperlink to a servlet page. By using display table
Item renderer in flex
Item renderer in flex  Hi..... How does item renderer work? How do I add item renderer at runtime? Please me the right answer so i cam implement this in my apps. Thanks  Ans: The base class for Spark item
hyperlink - JSP-Servlet
hyperlink  Hi! I am displaying bulk data in my page. It looks like some what senseless. Thats why I want to put a small link after two lines that is "more..." if user clicks on that link he will get entire data. I am not getting
JDBC: Get Column Details Example
JDBC: Get Column Details Example In this tutorial, we are describing how to get column details of a table using JDBC API. Get Column details... table. You can also put conditions to get column details by using LIKE/WHERE
searching inside a file for details
searching inside a file for details  i created a file with name,country,state etc...when i'm searching for the name, i have to get other details like country,state etc...please do help
Problem to display checkbox item
; xmlHttp.open("GET", url, true); xmlHttp.send(null); } function stateChange
Connecting to Database from a hyperlink in JSP - JSP-Servlet
Connecting to Database from a hyperlink in JSP  How can I connect to database by clicking on a hyperlink in a JSP Page.Can you please give me sample code for that? Thanks, Srinivasa Rao  Hi friend, insert code
Employee Details - JSP-Servlet
, it is not possible to get the alert box in home page
hyperlink the pages with diff-2 actions struts - Struts
hyperlink the pages with actions struts  How to make a hyperlink in struts?  a href = "login.do" > Login </a> ... would definitely get your answers. so first learn ithttp://www.roseindia.net
how to code-updating some details n some details r unchanged
is-if the user want to change only contact n he want to get the remaining details...how to code-updating some details n some details r unchanged  i have created a page with empty text boxes,details are.... house
Show Hyperlink in HTML Page
Show Hyperlink in HTML Page       HTML is a HyperTextMarkupLanguage.The HTML uses a hyperlink...;/a>) tag is used for creating a text on which hyperlink is to be displayed
how to show hyperlink website on the same page
how to show hyperlink website on the same page  dear sir: i need to know how can you show a webiste on the same page. for example i want to show www.roseindia.net by clicking on roseindia in hyperlink that will be displayed
I am getting error.How can i get details
I am getting error.How can i get details  Exception in thread "main" java.sql.SQLException: Listener refused the connecti n with the following error: ORA-12505, TNS:listener does not currently know of SID given in connect
use data from database table as hyperlink value - JSP-Servlet
of the hyperlink in order to view the complete details of the row of the resultset. e.g.... as the hyperlink's value then pass to the next page and retrieve the complete details of the row...use data from database table as hyperlink value  I'm creating a web
Changing the message box to a specific color
Changing the message box to a specific color  How do you change the message box color to a specific color? I can get the color to change with each input but i cant give it a specific color. Example I'm trying to change
Compose mail by clicking on send mail button
Compose mail by clicking on send mail button  How i get microsof out look page opend for composing mail by just clicking on send mail button and when outlook page open then in to:my email id is written on my jsp page
retaining save dialog box even after clicking save button - Java Beginners
retaining save dialog box even after clicking save button  I am... "no" to that dialog box i'm unable to get the save dialog box again.how coulg i get it back??(even if i cal save dialog box again it would open again from
How to get specific index value from int buffer.
How to get specific index value from int buffer. In this tutorial, we will discuss how  to get specific index value from int buffer. IntBuffer... get(int index) The get() method reads int value at given index 
Jmagick write image to a specific folder
Jmagick write image to a specific folder  hi, I am writing the code for resizing the images into which the image will be get from one location and save the resized images to the another location. for example : get an image
How to get specific index value from long buffer.
How to get specific index value from long buffer. In this tutorial, we will discuss how  to get specific index value from long buffer. LongBuffer...; long get(int index) The get() method read long value at given
How to get specific index value from short buffer.
How to get specific index value from short buffer. In this tutorial, we will discuss how  to get specific index value from short buffer. ShortBuffer...; abstract short get( int index) The get() method reads is short
Item Renderer in AdvancedDataGrid
Item Renderer in AdvancedDataGrid: In this example you can see how we can use a item renderer property in AdvanceddataGrid control. The tag of item... a pie chart as a item renderer and displayed in AdvancedDataGrid. Example
Chart Item Event in Flex4
Chart Item Event in Flex4: Chart uses the ChartItemEvent when you perform the operation click on the chart Item. This event is the part of chart package... you will show the value of item when you click on the data item. If you click
enable hyperlink
enable hyperlink  How to enable hyperlink
How to get specific index value from ByteBuffer in java.
How to get specific index value from ByteBuffer in java.    ... will discuss how to get value of a given index from buffer. The ByteBuffer class is a container for handling data. The get(int index) method of ByteBuffer
select one item name throug combo box than other combobox show item price
select one item name throug combo box than other combobox show item price  i have one table in database item master..if i select one item name through combo box than other combobox show item price only select item name... how i
Os details access in java - Development process
Os details access in java  Hi, can anyone give me the code of accessing OS details in java such as os name,os type ,kernal etc.etc.?  Hi Prashant, You can get the system properties from the System.getProperty
Insert specific fields into table dynamically for each row.
Insert specific fields into table dynamically for each row.  ... will enter those details in a webpage. So that the field values will insert... details and just click done on first row and immediately he enters second row
link in the field of table on clicking he link the full data will displayed
link in the field of table on clicking he link the full data will displayed... and displaying it in a jsp page. I want set up a hyperlink in the name field so that on clicking on any one of the name of the student, the whole data
Insert specific fields into table dynamically for each row.
Insert specific fields into table dynamically for each row.  There is a table containing 20 fields and 2 of those are empty. The administrator will enter those details in a webpage. So that the field values will insert
pass a variable(friends name) through a hyperlink in to another jsp.
pass a variable(friends name) through a hyperlink in to another jsp.  hi friends, i am developing a site in jsp. i have some problem,plz tell me... in to the next page,but i want to pass a specific friend name which i was clicked,plz tell
pass a variable(friends name) through a hyperlink in to another jsp.
pass a variable(friends name) through a hyperlink in to another jsp.  hi friends, i am developing a site in jsp. i have some problem,plz tell me... page,but i want to pass a specific friend name which i was clicked,plz tell me
Skinning Data Item in Chart in Flex4
Skinning Data Item in Chart in Flex4: In this section you can see how we can provide the skin to data item in chart control. We will use the itemRenderer for providing the skin to data item. In this example we change
how to retrive other details with an image - Swing AWT
how to retrive other details with an image  hello I m trying..... followingis my code..plz advice me how to get both values as well as image at a same...("Select visitor_firstname,Type_code, image_data from visiting_details where Ticket
using list iterator create student details - JavaMail
and then after sorting them according to some specific values we would have to add
Jdatechooser : not able to fetch date in a specific format
Jdatechooser : not able to fetch date in a specific format  get date... at this website now i can't fetch date from it ina a specific format... but i am able to get date i am using netbeans i have tried all groups no one seems to know
autogeneration of a random number and displaying it as a alert message to the user on clicking submit
autogeneration of a random number and displaying it as a alert message to the user on clicking submit  Hi, In my project order purchase system under... is generated it should be inserted into database along with the details of addform when

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.