can u plz try this program

Ads
 

can u plz try this program

View Answers

November 18, 2008 at 12:28 AM

Hi friend,

form code
------------------
<html>



<head>



<title>User information</title>

</head>



<body>

<br><br><br>

<div align="center">

<center>

<table border="1" cellpadding="0" cellspacing="0" width="400px" height="69">

<tr>

<td width="859" height="69">

<form method="POST" action="userInfomAction.jsp">



<h1 align="center">&nbsp;User Information Form</h1>

<div align="left">

<table border="1" cellpadding="0" cellspacing="0" width="400px">



<tr>

<td width="50%"><b>Name:</b></td>

<td width="50%"><input type="text" name="name" size="20"></td>

</tr>

<tr>

<td width="50%"><b>Last Name:</b></td>

<td width="50%"><input type="text" name="lsname" size="20">

</td>

</tr>

<tr>

<td width="50%"><b>Age :</b></td>

<td width="50%"><input type="text" name="age" size="10">

</td>

</tr>



</table>

</div>

<p align="center"><input type="submit" value="Submit" name="submit">

<input type="reset" value="Reset" name="B2"></p>

</form>

<a href="showDataAction.jsp"><b>Click for Show Data</a></b>

</td>

</tr>

</table>

</center>

</div>



</body>



</html>


-------------------------

November 18, 2008 at 12:29 AM

data insert action code:
----------------------------

<%@page language="java" import="java.sql.*" %>



<%

Connection con = null;
String url = "jdbc:mysql://192.168.10.211:3306/";;
String db = "amar";
String driver = "com.mysql.jdbc.Driver";
String userName ="amar";
String pass="amar123";



try{

Class.forName(driver);

con = DriverManager.getConnection(url+db,userName,pass);



try{

Statement st = con.createStatement();

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

String lsname = request.getParameter("lsname");
String age = request.getParameter("age");



int val = st.executeUpdate("insert into userinform(name,lsname,age) values('"+name+"','"+lsname+"','"+age+"')");

con.close();

out.println("Successfully insert data into Database");

}



catch(SQLException ex){

System.out.println("SQL satatment not found");

}

}

catch(Exception e){

e.printStackTrace();

}

%>

<br>

<a href="userInform.jsp">Home Page</a>

---------------------------------------


November 18, 2008 at 12:30 AM

Data display code:

----------------------------

<%@ page language="java" import="java.io.*, java.sql.*" %>

<html>

<head>

<title>display data</title>

</head>

<body>

<center>

<H1>Display Record From Database<H1>

<br>

<table border="1" cellpadding="0" cellspacing="0" width="500px" height="69">

<tr>

<td></td>

</tr>

<tr>

<td><b>Id<b></td>

<td><b>Name<b></td>

<td><b>Last Name<b></td>
<td><b>Age <b></td>

<td><b>Delete<b></td>
<td><b>Edit<b></td>

</tr>



<%

Connection con = null;

String url = "jdbc:mysql://192.168.10.211:3306/";;

String db = "amar";



String driver = "com.mysql.jdbc.Driver";

String username = "amar";

String password = "amar123";



try{

Class.forName(driver);

con = DriverManager.getConnection(url+db,username,password);



try{

Statement st = con.createStatement();

String sqlQuery = "Select * from userinform";

ResultSet rs = st.executeQuery(sqlQuery);

int sno = 0;

while(rs.next()){

sno++;

%>



<tr style="background-color:#CCFFFF;">

<td><%=sno%></td>

<td><%=rs.getString("name")%></td>

<td><%=rs.getString("lsname")%></td>
<td><%=rs.getString("age")%></td>

<td><a href = "deleteAction.jsp?id=<%=rs.getInt("id")%>">Delete</a></td>
<td><a href = "Updaterecord.jsp?id=<%=rs.getInt("id")%>">Edit</a></td>

</tr>



<%



}



rs.close();

con.close();

st.close();

}

catch(SQLException ex){

System.out.println("SQL satatment not found");

}

}

catch(Exception e){

e.printStackTrace();

}

%>



</table>

<a href="userInform.jsp">Home Page</a>

</center>

</body>

</html>

November 18, 2008 at 12:31 AM

Data delete action code:

-----------------------

<%@page language="java" import="java.sql.*" %>



<%

Connection con = null;
String url = "jdbc:mysql://192.168.10.211:3306/";;
String db = "amar";
String driver = "com.mysql.jdbc.Driver";
String userName ="amar";
String pass="amar123";



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

System.out.println("id:"+id);

try{

Class.forName(driver);

con = DriverManager.getConnection(url+db,userName,pass);



try{

Statement st = con.createStatement();



String sqlQuery = "delete from userinform where id="+id;

int delete = st.executeUpdate(sqlQuery);

con.close();

out.println("Successfully Delete data into Database");

}



catch(SQLException ex){

System.out.println("SQL satatment not found");

}

}

catch(Exception e){

e.printStackTrace();

}

%>

--------------------------------

November 18, 2008 at 12:32 AM

Data edit code.
---------------------

<%@ page language="java" import="java.io.*, java.sql.*" %>
<%
int id=0;
Connection con = null;
String url = "jdbc:mysql://192.168.10.211:3306/";;
String db = "amar";
String driver = "com.mysql.jdbc.Driver";
String userName ="amar";
String password="amar123";



String name="";
String lastName="";
String age = "";
if(request.getParameter("id")!=null && request.getParameter("id")!="")
{

id = Integer.parseInt(request.getParameter("id").toString());


try{

Class.forName(driver);
con = DriverManager.getConnection(url+db,userName,password);

Statement st = con.createStatement();

String sqlQuery = "Select * from userinform where id="+id;
System.out.println("sqlQuery>>>>>>>" + sqlQuery);

ResultSet rs = st.executeQuery(sqlQuery);
if(rs.next())
{
name = rs.getString(2);
lastName = rs.getString(3);
age = rs.getString(4);
}
}
catch(Exception e) {
System.out.println(e.getMessage());
}

}
%>
<html>
<head>
<title>update record</title>
</head>
<body>
<center>
<table border="0" width="400px" cellspacing="0" cellpadding="0">
<tr>
<td width="100%">
<center>
<h2><font color="#FF0033">Update data into database</font></h2></center>
<form name="updateForm" action="updateRecordAction.jsp" method="GET" >
<input type="hidden" name="id" value="<%=id%>">
<table border="1" width="400px" cellspacing="0" cellpadding="0" bgcolor="#CCFFCC">
<tr>
<td width="50%"><b>Id:</b></td>
<td width="50%" valign="right">
<input type="text" name="id" value="<%=id%>"> </td></tr>
<td width="50%"><b>Name</b></td>
<td width="50%">
<input type="text" name="name" value="<%=name%>"></td></tr>
<td width="50%"><b>Last Name</b></td>
<td>
<input type="text" name="lsname" value="<%=lastName%>"><br/></td></tr>

<td width="50%"><b>Age </b></td>
<td>
<input type="text" name="age" value="<%=age%>"><br/></td>

</tr>
<tr><td><center>
<input type="submit" name="update" value="Update"></center></td></tr>

</tr>
</table>
</form>
</td>
</tr>
</table>
</center>
</body>
</html>

------------------------------

November 18, 2008 at 12:35 AM

Edit action code:

-----------------------------

<%@ page language="java" import="java.sql.*" %>

<%
Connection con = null;
String url = "jdbc:mysql://192.168.10.211:3306/";;
String db = "amar";
String driver = "com.mysql.jdbc.Driver";
String userName ="amar";
String password="amar123";

System.out.println( "uri : "+ request.getRequestURI());
int id = Integer.parseInt(request.getParameter("id"));
System.out.println("id:"+id);
String name = request.getParameter("name");
String lsname = request.getParameter("lsname");
String age = request.getParameter("age");

try{
Class.forName(driver);
con = DriverManager.getConnection(url+db,userName,password);
try{
Statement st = con.createStatement();
String sqlQuery ="update userinform set name='"+name+"',lsname='"+lsname+"',age='"+age+"' where id="+id;
int update = st.executeUpdate(sqlQuery);
con.close();
out.println("successfully update data from database!");

}
catch (SQLException ex){
System.out.println("SQL statement is not executed!");
}
}
catch (Exception e){
e.printStackTrace();
}

%>
<br>
<a href="showDataAction.jsp">Edit Page</a>

-----------------------------------

Visit for more information.

http://www.roseindia.net/jsp/user-search.shtml

Thanks.

Amardeep

Ads









Related Tutorials/Questions & Answers:
plz help me any one as fast as u can
plz help me any one as fast as u can  A thief Muthhooswamy planned... is given in an array. Write a program to find out the total number of jumps he will make to escape from the jail. Input Specifications Your program must read 4
can u plz help out how to attach file directly & send to a particular mail id
can u plz help out how to attach file directly & send to a particular mail id  i am building a project online LEAVE MANAGEMENT SYSTEM to our coll mini project so if a faculty write all details abt leave & shd send to HOD
Advertisements
how can u reduce the size of textfield?
how can u reduce the size of textfield?  how can u reduce the size of textfield? thanks in advance   import javax.swing.*; public class ReduceTextField extends JFrame { public static void main(String
plz anyone can solve my
plz anyone can solve my  creat an applet prog which accepts the details of 10 customers like name , address , city , ect. and display it   import java.awt.*; import javax.swing.*; import java.awt.event.*; import
plz help me find a program
plz help me find a program  plz help..i want a source code in jsp for order processing
can u help me to get a calendar with color codes on days ???
can u help me to get a calendar with color codes on days ???  hi roseindia, Can you help me to get the code, I need a calendar with color codes.i,e....... NOTE:Its a calendar not a date-picker PLZ can you help me, its very urgent
CAN U HELP ME TO CODE IN JSP FOR ONLINE VOTING SYSTEM
CAN U HELP ME TO CODE IN JSP FOR ONLINE VOTING SYSTEM  can u help me to code in jsp for online voting system
plz try to clear my doubt for shuffling multi-dimensional array
plz try to clear my doubt for shuffling multi-dimensional array  hi, if v r using Arrays.asList() means, it may shuffle the row wise list only... v...??? plz help me... thanks in advance   Hi Friend, Try the following code
Write a program that replaces a, e, i, o, u in Java2
Write a program that replaces a, e, i, o, u in Java2  Write a program that replaces a, e, i, o, u, with the letter z. (i.e. John Smith -> Jzhn Smzth. Also the program reverses the users name (i.e. John Smith -> htimS nhoJ
How Jdbc program can be run??
How Jdbc program can be run??  import java.sql.*; import java.util.*; class MyDbCode3 { public static void main(String [] args) { try...; System.out.println("Enter bookid:"); id=kb.nextInt(); try
swing program plz urgent sir - Java Beginners
swing program plz urgent sir   hi sir,i waan a jtable swings program table having column names "itemid","price".Initially table having single empty row.whenever we click the "enter" button automatically new row will be insert
Plz Provide correct program code for all questions.
Plz Provide correct program code for all questions.   Write a program... of n numbers? Develop a program that accepts the area of a square and will calculate its perimeter. Develop the program calculateCylinderVolume., which accepts
how the answer is 13 can anyone explain plz
how the answer is 13 can anyone explain plz  public class that { public static void main(String arr[]) { int i=3; int j=1; while(i<4) { //j=i; i=i+j/2; } System.out.println(i
Nested Try-Catch Blocks
Nested Try-Catch Blocks       In Java we can have nested try and catch blocks. It means that, a try statement can be inside the block of another try. If an inner try
this code gives addition of 2 numbers in j2me..but the code is not executing ..can u pls find out the error...??
this code gives addition of 2 numbers in j2me..but the code is not executing ..can u pls find out the error...??  import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class add1 extends MIDlet implements
displaying List of records from database in a jsp using ajax, onclick it should display the results ?? its urgent can u help me
displaying List of records from database in a jsp using ajax, onclick it should display the results ?? its urgent can u help me   displaying List... ?? its urgent can u help me
ModuleNotFoundError: No module named 'u'
ModuleNotFoundError: No module named 'u'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'u... library. You can install u python with following command: pip install u
ModuleNotFoundError: No module named 'u'
ModuleNotFoundError: No module named 'u'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'u... library. You can install u python with following command: pip install u
how can i add wirecard option(or button ) at my web page plz tell all steps? View Answers
how can i add wirecard option(or button ) at my web page plz tell all steps? View Answers  how can i add wirecard option(or button ) at my web page plz tell all steps? View Answers
without writing web.xml file we can write servlet program
without writing web.xml file we can write servlet program  Sir Morning... Sir I have one Question "without writing web.xml file we can write servlet program". if yes which way? if no why? but without use Annotation........ Plz
Java try, catch, and finally
Java try, catch, and finally         The try, catch, and finally keywords are Java keywords that are used to handle the exception in a program.  The mechanism to handle
plz give me program to this: Given a string and a number ‘n’, find the ‘n’th distinct repeating character.
plz give me program to this: Given a string and a number ?n?, find the ?n?th distinct repeating character.    Given a string and a number ?n?, find the ?n?th distinct repeating character. For example, Input: Abracadabra, 1
Can u print in turbo c 9 8 7 6 5 4 3 2 1 0 using pre increment operator Only use print ++a in the same printf() command ten times)
Can u print in turbo C  Can u print in turbo c 9 8 7 6 5 4 3 2 1 0 using pre increment operator Only use print ++a in the same printf() command ten times
Can u print in turbo c 9 8 7 6 5 4 3 2 1 0 using pre increment operator Only use print ++a in the same printf() command ten times)
Can u print in turbo c 9 8 7 6 5 4 3 2 1 0 using pre increment operator Only use print ++a in the same printf() command ten times)  Can u print in turbo c 9 8 7 6 5 4 3 2 1 0 using pre increment operator Only use print
**Connectivity is not getting done in this program plz check it out wat is the problem with that Although i've made tables in MA-ACCESS**
**Connectivity is not getting done in this program plz check it out wat...) { int a = Integer.parseInt(id.getText()); a++; try...(id.getText()); a--; try
ModuleNotFoundError: No module named 'pexpect-u'
have to install padas library. You can install pexpect-u python with following...ModuleNotFoundError: No module named 'pexpect-u'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'u-cli'
ModuleNotFoundError: No module named 'u-cli'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'u-cli... padas library. You can install u-cli python with following command: pip
ModuleNotFoundError: No module named 'plz'
ModuleNotFoundError: No module named 'plz'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'plz... library. You can install plz python with following command: pip install
ModuleNotFoundError: No module named 'plz'
ModuleNotFoundError: No module named 'plz'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'plz... library. You can install plz python with following command: pip install
how can i write this program ?please suggest me
how can i write this program ?please suggest me  Program to calculate the sum of two big numbers (the numbers can contain more than 1000 digits). Don't use any library classes or methods (BigInteger etc
it is a linux program is there anyone who can help me out with it?
it is a linux program is there anyone who can help me out with it?  Write a Bash script that prompts the user for a user-ID and displays the corresponding user√Ę‚?¨‚?Ęs login name, owner√Ę‚?¨‚?Ęs name, and his/her home directory

Ads