how to make employee i card

Ads
 

how to make employee i card

hello friends

can anyone help me..

I have to make a project to make Identity card for employees...but i am facing problems with database and jsp connection ...

also tell me how to retrive data such as name and image at a paticular place on the I-card...plz reply as soon as possible....

Thank you in advance

Rohan

View Answers

September 17, 2012 at 11:42 AM

Here is a jsp code that retrieves the name and image from the database and display it in the html table.

1)data.jsp:

<%@ page import="java.sql.*,java.io.*,java.util.*" %> 
<HTML>
 <table border="1">
 <tr><th>Name</th><th>Address</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 data";
    ResultSet rs = stmt.executeQuery(strQuery);
    while(rs.next()){
       %>
      <tr>
      <td><%=rs.getString("name")%></td><td><%=rs.getString("address")%></td>
      <td align="center">

<img src="image.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)image.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 data 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();
  }
%>

Ads









Related Tutorials/Questions & Answers:
how to make employee i card
how to make employee i card  hello friends can anyone help me.. I have to make a project to make Identity card for employees...but i am facing... such as name and image at a paticular place on the I-card...plz reply as soon
How to make a valentine card
How to make a valentine card Learn a easy technique to make a valentine card. It is very interesting design, I hope you will like it. Follow now step by step instruction to make it. New File: Take a new file
Advertisements
how can i make monthly register ?
how can i make monthly register ?  how can i make monthly register ? iam using jdeveloper
how I make the numbers in descending order ?
how I make the numbers in descending order ?   public class Quiz1...]+" "); } } thanks how I make the numbers in descending order ?   ...(System.in); int number [] = new int [20]; int num =2; for(int i =0; i<
How do I write a program to manage an employee's business and personal contacts?
How do I write a program to manage an employee's business and personal contacts?  A. Input Requirements 1. Include a prompt that allows the user to enter a command from the following four options, repeating the process
how do i make a phone call from my app without quitting my application
how do i make a phone call from my app without quitting my application  hi, I am working on creating a call application, i am making a call from my... quits , i want my application to go to background and resume on call end ...please
how to make multiple rectangles
how to make multiple rectangles  I,m a beginner , m sorry if the question is really simple i have an array list.I want to print the contents..."); classlist.add("card"); classlist.add("yes"); for(int i=0;i<=classlist.size();i
How to make selectOneMenu scrollable
How to make selectOneMenu scrollable  how to make the selectOneMenu scrollable? I have around 20 values in drop down and i want the scrollable functionality after 5 values. Kindly reply as soon as possible. Thanks Shikha
how to make this pattern???
how to make this pattern???  how to make following pattern in javascript
How to make first JSP page?
How to make first JSP page?  Hello, How I can make first JSP page? Thanks
how to make exampage in jsp ?
how to make exampage in jsp ?  how to make a online exam page in jsp and servelet
how to make a program on array
how to make a program on array  When you make a program on array that the element will move downward and upward and when you input twice 0 then thats the time that it will not move. pls. give me a formula...tnx
how to make multiple choice questions
how to make multiple choice questions  I have to make a multiple choice choice using JSP/Servlets. I created a a session bean for the questions and answers. how to associate group of questions to a user? so each user will have
How to make query and abstraction in Java
How to make query and abstraction in Java  Hi, I read the lessons you have in the sites. They are really useful. However, I could not write codes... PostgreSQL database, and I want to make a query and abstraction for a table. Could
How to make a transparent text
How to make a transparent text Learn how to make a transparent...) and make formatting as looking here. Write Text: Now write your text as you like. I have written here "Text". After writing text make copy (Ctr
How to make a sharpen image
How to make a sharpen image I am going to make a sharp picture effect, I have here a dog picture to modify. Open Picture: Capture a picture to make sharp effect. Effects: Go to Image Menu
how make excel
how make excel  how make excel spreadsheet IN JAVA. please send this code argently   Hello Friend, Try the following code: import java.io.*; import org.apache.poi.hssf.usermodel.HSSFSheet; import
How to make bubbles, make bubbles, bubbles
How to make bubbles      ... make another bubbles as I have done here. This is final result. Look here... to make it easily to draw. New File: First take colored background file. Draw
How to Make iPhone Window Application
How to Make iPhone Window Application  Hi, For Making iphone window application, what parameters i have to follow or provide example related to iphone window application. Thanks
How to make first JSP page?
How to make first JSP page?  Hello, How I can make first JSP page? Thanks   HI, Beginner can learn JSP from writing the first Program... tutorial: How to make my first JSP page? Thanks
how to make paging with function ?
how to make paging with function ?  how to make paging with function ?   //this page is display.php <?php</p> $con=mysql_connect("localhost","root",""); if(!$con) { die("you can connect please check". mysql
how to make a field left justification
how to make a field left justification  how to make a field left justification.need code.thanks in advance
how to make a label left alignment?
how to make a label left alignment?  how to make a label left alignment
How to make a button of different behaviour?
How to make a button of different behaviour?  Suppose In a jsp page I...").value,......); Now I want the SAVE button to be changed to UPDATE button id... ajaxInsertUpdateData(document.getElementByID("btnSave1").value,......); How to do
how to make paging with class and ajax
how to make paging with class and ajax  paging with class and ajax
How to make a chain, make a chain, chain
How to make a chain       To learn how to design a chain in the photoshop has become so easy by this example, it has some important instruction to make it so follow
How to make halo effect
How to make halo effect       Now get ready to learn a simple way to make a halo effect on the picture, follow to make it. Take a picture: Capture any picture to give
How can I do it? .click();
want that it make mouseup in this element. How can I do it, because if I write...How can I do it? .click();  I have a very unusual problem. I want to make a script like this: <script> x = document.getElementById
how i want to create a coding by this question?
how i want to create a coding by this question?  Design and write a class named Person and its two subclasses named Student and Employee. Make Lecturer and Admin subclasses of Employee. A person has a name, address, phone number
how to make paging with class and ajax
how to make paging with class and ajax  paging with class and ajax...,$table,$totalres,$totalpages; var $r,$i;</p>...;"; for ($i=0; $i < mysql_num_fields($this->sql); $i++) //Table Header
How to make a bone, make a bone, a bone
How to make a bone       This example bone design example, It is very easy. If you are looking for, please follow now. New File: Create a new file. Rounded rectangle

Ads