JSP Client Application

JSP Client Application

JSP client application in Java - Can anyone give an example?

View Answers

April 19, 2008 at 8:31 PM

Hi friend,

This is form code.

<html>
<head>
<title>Untitled Page</title>

</head>

<body>

<table id="t1" border="1" width="50%" cellspacing="0" cellpadding="0" bgcolor="#F2FFF5">
<tr>
<td width="100%">
<form method="POST" action="adding-Action.jsp">

<h1>Row add and Delete Table</h1>
<table border="1" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="50%"><b>Student Id:</b></td>
<td width="50%"><input type="text" name="stuid" size="5"></td>
</tr>
<tr>
<td width="50%"><b>Student Name:</b></td>
<td width="50%"><input type="text" name="stuname" size="20"></td>
</tr>
<tr>
<td width="50%"><b>Class:</b></td>
<td width="50%"><input type="text" name="room" size="20"></td>
</tr>
<tr>
<td width="50%"><b>Address:</b></td>
<td width="50%"><input type="text" name="address" size="50"></td>
</tr>
<tr>
<td width="50%"><b>Father Name:</b></td>
<td width="50%"><input type="text" name="faname" size="20"></td>
</tr>
<tr>
<td width="50%"><b>City:</b></td>
<td width="50%"><input type="text" name="city" size="20"></td>
</tr>
</table>
<p><input type="submit" value="Submit" name="submit">
<input type="reset" value="Reset" name="reset">

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

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


April 19, 2008 at 8:32 PM

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

<%

Connection con = null;
String url = "jdbc:mysql://localhost:3306/";;
String db = "register";
String driver = "com.mysql.jdbc.Driver";
java.util.Date date;
String s=null;
try{
Class.forName(driver);
con = DriverManager.getConnection(url+db,"root","root");
try{
Statement st = con.createStatement();
String stuid=request.getParameter("stuid");
String stuname=request.getParameter("stuname");
String room=request.getParameter("room");
String address=request.getParameter("address");
String faname = request.getParameter("faname");
String city = request.getParameter("city");

int val = st.executeUpdate("insert student_detail values('"+stuid+"','"+stuname+"','"+room+"','"+address+"','"+faname+"','"+city+"')");

con.close();
out.println("<b>Successfully insert data</b><br/>");
out.println("<br/><a href=studenet-retrive-Action.jsp><b>Retrive Data From Database</b></a>");
}
catch (SQLException ex){
System.out.println("SQL statement is not executed!");
}
}
catch (Exception e){
e.printStackTrace();
}

%>
-----------------------------

April 19, 2008 at 8:34 PM

<%@ page language="java" import="java.sql.*,java.util.*,java.text.*" %>
<html>
<title>Retrive value from database</title>
<head>
<script type="text/javascript">
function addRowToTable(){
var tbl = document.getElementById('tblSample');
var lastRow = tbl.rows.length;
// if there's no header row in the table, then iteration = lastRow + 1
var iteration = lastRow;
var row = tbl.insertRow(lastRow);

// left cell
var cellLeft = row.insertCell(0);
var textNode = document.createTextNode(iteration);
textNode.onkeypress = keyPressTest;
cellLeft.appendChild(textNode);

// right cell
var cellRight = row.insertCell(1);
var el = document.createElement('input');
el.type = 'text';
el.name = 'txtRow' + iteration;
el.id = 'txtRow' + iteration;
el.size = 30;

el.onkeypress = keyPressTest;
cellRight.appendChild(el);

var cellRight = row.insertCell(2);
var sel = document.createElement('input');
sel.type = 'text';
sel.name = 'txtRow' + iteration;
sel.id = 'txtRow' + iteration;
sel.size = 30;

sel.onkeypress = keyPressTest;
cellRight.appendChild(sel);

var cellRight = row.insertCell(3);
var sell = document.createElement('input');
sell.type = 'text';
sell.name = 'txtRow' + iteration;
sell.id = 'txtRow' + iteration;
sell.size = 30;

sell.onkeypress = keyPressTest;
cellRight.appendChild(sell);

}
function keyPressTest(e, obj){
var validateChkb = document.getElementById('chkValidateOnKeyPress');
if (validateChkb.checked){
var displayObj = document.getElementById('spanOutput');
var key;
if(window.event){
key = window.event.keyCode;
}
else if(e.which){
key = e.which;
}
var objId;
if (obj != null){
objId = obj.id;
}
else{
objId = this.id;
}
displayObj.innerHTML = objId + ' : ' + String.fromCharCode(key);
}
}
function removeRowFromTable(){
var tbl = document.getElementById('tblSample');
var lastRow = tbl.rows.length;
if(lastRow > 2) tbl.deleteRow(lastRow - 1);
}
function validateRow(frm){
var chkb = document.getElementById('chkValidate');
if(chkb.checked){
var tbl = document.getElementById('tblSample');
var lastRow = tbl.rows.length - 1;
var i;
for (i=1; i<=lastRow; i++) {
var aRow = document.getElementById('txtRow' + i);
if (aRow.value.length <= 0) {
alert('Row ' + i + ' is empty');
return;
}
}
}
openInNewWindow(frm);
}

</script>
</head>


April 19, 2008 at 8:34 PM

<body>
<h2><font color="#CC3366">Retrive data from database</font></h2>
<table border="0" width="50%" cellspacing="0" cellpadding="0">
<tr>
<td width="50%">
<form method="POST">
<table border="1" width="100%" cellspacing="0" cellpadding="0" bgcolor="#D9FFFF">
<tr>
<td width="50%" valign="right"><b>Student Id</b></td>
<td width="50%" valign="right"><b>Student Name</b></td>
<td width="50%" valign="right"><b>Class</b></td>
<td width="50%" valign="right"><b>Address</b></td>
<td width="50%" valign="right"><b>Father Name</b></td>
<td width="50%" valign="right"><b>City</b></td>
<td width="50%" valign="right"><b>Delete</b></td>
<td width="50%" valign="right"><b>Addrow</b></td>
<td width="50%" valign="right"><b>Removes</b></td>
<%
Connection con = null;
String url = "jdbc:mysql://localhost:3306/";;
String db = "register";
String driver = "com.mysql.jdbc.Driver";
try{
Class.forName(driver);
con = DriverManager.getConnection(url+db,"root","root");
try{
Statement st = con.createStatement();
String query = "SELECT * FROM student_detail";
ResultSet rs = st.executeQuery(query);
while (rs.next()) {
%>
</tr>
<tr>
<td width="50%" valign="right"><%out.println(rs.getString(1));%></td>
<td width="50%" valign="right"><%out.println(rs.getString(2));%></td>
<td width="50%" valign="right"><%out.println(rs.getString(3));%></td>
<td width="50%" valign="right"><%out.println(rs.getString(4));%></td>
<td width="50%" valign="right"><%out.println(rs.getString(5));%></td>
<td width="50%" valign="right"><%out.println(rs.getString(6));%></td>

<td>

<a href="studene-record-DeleteAction.jsp?id=<%=rs.getInt("stuid")%>"><input type="checkbox"></a>
</td>
<td><input type="button" value="Add" onclick="addRowToTable();" /></td>
<td><input type="button" value="Remove" onclick="removeRowFromTable();" /></td>
</tr>
<%}
out.println("<br/><a href=rowadd-and-delete.jsp><b>Home</b></a>");
rs.close();
con.close();

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

<table border="1" id="tblSample" cellspacing="0" cellpadding="0">
<tr>
<td width="25">1</td>
<td><input type="text" name="txtRow1" id="txtRow1" size="30" onkeypress="keyPressTest(event, this);" /></td>
<td>
&nbsp
</td>
</tr>
</table>

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

April 19, 2008 at 8:35 PM

This is delete code.

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

<%
String strId =request.getParameter("id");
int id = Integer.parseInt(strId);
Connection con = null;
String url = "jdbc:mysql://localhost:3306/";;
String db = "register";
String driver = "com.mysql.jdbc.Driver";
try{
Class.forName(driver);
con = DriverManager.getConnection(url+db,"root","root");
try{
Statement st = con.createStatement();
String username=request.getParameter("stuname");
String room=request.getParameter("room");
String address=request.getParameter("address");
String faname=request.getParameter("faname");
String city=request.getParameter("city");

int in = st.executeUpdate("DELETE FROM student_detail where stuid ="+id);
con.close();
out.println("successfully updated");
}
catch (SQLException ex){
System.out.println("SQL statement is not executed!");
}
}
catch (Exception e){
e.printStackTrace();
}
%>









Related Tutorials/Questions & Answers:
jsp application
jsp application  write a jsp application that will receive an integer from the client , check if the integer is even or odd and send the result to the client
WEB APPLICATION IN JSP
WEB APPLICATION IN JSP  Can you help me with a JSP code which can search and update existing data in mysql database
Advertisements
JSP Application Object
JSP Application Object  JSP Application Object?   Application Object is used to share the data with all application pages. Thus, all users.... The Application object is accessed by any JSP present in the application. The class
Web application - JSP-Servlet
Web application   Helo can you please help me in knowing how to use jsp/servlets which allows users to post question in a forum so that other users can also view the question and respond to it.For instance your application here
Java Client Application
Java Client Application  Java Client Application
how to create chat application in jsp?
how to create chat application in jsp?  i am developing online web portal using jsp, i need to communicate with admin, so i need integrate with the chat applicaion through the webportal
Add a jsp file to java application
Add a jsp file to java application  How to add a JSP file to java application?   <html> <head> <title>Include another... a file,having any application,code or any content..</h2><br/> <
how to create chat application in jsp?
Creating Chat application in JSP  Creating Chat application in JSP i am developing online web portal using jsp, i need to communicate with admin, so i need integrate with the chat applicaion through the webportal
To publish jsp web application in intranet
To publish jsp web application in intranet  I am making web application in jsp with netbean. I want to publish this web application in LAN.... So please suggest some steps to publish jsp application. Your suggestion
Java Client Application example
Java Client Application example  Java Client Application example
Java HTML Client Application
Java HTML Client Application  Java HTML Client Application
JSP to client side - JSP-Servlet
JSP to client side  Hi I have a JSP(graph.jsp) page which calls a servlet and get the output. The output is a JSON object. I want to use the same to plot a graph in flotr. How can I use the same
application using AJAX and JQuery and also use JSP
application using AJAX and JQuery and also use JSP   i need create an application using AJAX and JQuery and also use JSP
JSP implicit object "application"
JSP IMPLICIT OBJECT application In this section, we will discuss about JSP... in an application. It means the "application" object is accessed by any JSP... of Application object is used to write a text string to the JSP Container?s default log
Simple Bank Application in JSP
Simple Bank Application in JSP   ... application in jsp . In this application user can Update the User Profile, Cash... transaction report  for particular time period. We run this Bank Application
Online Quiz Application in JSP
Online Quiz Application in JSP  ... are going to implement of Online quiz application using of JSP. Step 1: Create... quiz question and answer form using with JSP or JDBC database.  Here
How to provide navigation in quiz application using jsp?
How to provide navigation in quiz application using jsp?  hi everyone. i am using jsp with mysql connectivity. i have to retrieve questions from db one at a time. on clicking the next it should go the next question
how to integrate chat application with jsp and servlet?
how to integrate chat application with jsp and servlet?  I was developing online web portal in jsp and servlet , in this web portal communicate with maintain admin so i desired to integrate with chat applicaton in this web portal
sample JSP&Servlet application required? - JSP-Servlet
sample JSP&Servlet application required?  hey all iam new...://www.roseindia.net/servlets/web-application.shtml http://www.roseindia.net/jsp/loginbean.shtml http://www.roseindia.net/jsp/bank.shtml Hope that the above links
multi client mobile chat application
multi client mobile chat application  plz help me for creating wap based mobile chat application in neatbean. or simply multi client mobile chat application. its urgently thanx
How to sent mails through jsp application
How to sent mails through jsp application  when i fill the form, and submit it, then a mail should be sent to persons mentioned in the form and i want to conect the jsp page to database
How to sent mails through jsp application
How to sent mails through jsp application  when i fill the form, and submit it, then a mail should be sent to persons mentioned in the form and i want to conect the jsp page to database
How to sent mails through jsp application
How to sent mails through jsp application  when i fill the form, and submit it, then a mail should be sent to persons mentioned in the form and i want to conect the jsp page to database
How to sent mails through jsp application
How to sent mails through jsp application  when i fill the form, and submit it, then a mail should be sent to persons mentioned in the form and i want to conect the jsp page to database
How to sent mails through jsp application
How to sent mails through jsp application  when i fill the form, and submit it, then a mail should be sent to persons mentioned in the form and i want to conect the jsp page to database
How to sent mails through jsp application
How to sent mails through jsp application  when i fill the form, and submit it, then a mail should be sent to persons mentioned in the form and i want to conect the jsp page to database
How to sent mails through jsp application
How to sent mails through jsp application  when i fill the form, and submit it, then a mail should be sent to persons mentioned in the form and i want to conect the jsp page to database
How to sent mails through jsp application
How to sent mails through jsp application  when i fill the form, and submit it, then a mail should be sent to persons mentioned in the form and i want to conect the jsp page to database
How to sent mails through jsp application
How to sent mails through jsp application  when i fill the form, and submit it, then a mail should be sent to persons mentioned in the form and i want to conect the jsp page to database
How to sent mails through jsp application
How to sent mails through jsp application  when i fill the form, and submit it, then a mail should be sent to persons mentioned in the form and i want to conect the jsp page to database
How to sent mails through jsp application
How to sent mails through jsp application  when i fill the form, and submit it, then a mail should be sent to persons mentioned in the form and i want to conect the jsp page to database
How to sent mails through jsp application
How to sent mails through jsp application  when i fill the form, and submit it, then a mail should be sent to persons mentioned in the form and i want to conect the jsp page to database
How to sent mails through jsp application
How to sent mails through jsp application  when i fill the form, and submit it, then a mail should be sent to persons mentioned in the form and i want to conect the jsp page to database
How to sent mails through jsp application
How to sent mails through jsp application  when i fill the form, and submit it, then a mail should be sent to persons mentioned in the form and i want to conect the jsp page to database
How to sent mails through jsp application
How to sent mails through jsp application  when i fill the form, and submit it, then a mail should be sent to persons mentioned in the form and i want to conect the jsp page to database
How to sent mails through jsp application
How to sent mails through jsp application  when i fill the form, and submit it, then a mail should be sent to persons mentioned in the form and i want to conect the jsp page to database
How to sent mails through jsp application
How to sent mails through jsp application  when i fill the form, and submit it, then a mail should be sent to persons mentioned in the form and i want to conect the jsp page to database
How to sent mails through jsp application
How to sent mails through jsp application  when i fill the form, and submit it, then a mail should be sent to persons mentioned in the form and i want to conect the jsp page to database
How to sent mails through jsp application
How to sent mails through jsp application  when i fill the form, and submit it, then a mail should be sent to persons mentioned in the form and i want to conect the jsp page to database
How to sent mails through jsp application
How to sent mails through jsp application  when i fill the form, and submit it, then a mail should be sent to persons mentioned in the form and i want to conect the jsp page to database
How to sent mails through jsp application
How to sent mails through jsp application  when i fill the form, and submit it, then a mail should be sent to persons mentioned in the form and i want to conect the jsp page to database
How to sent mails through jsp application
How to sent mails through jsp application  when i fill the form, and submit it, then a mail should be sent to persons mentioned in the form and i want to conect the jsp page to database
How to sent mails through jsp application
How to sent mails through jsp application  when i fill the form, and submit it, then a mail should be sent to persons mentioned in the form and i want to conect the jsp page to database
How to sent mails through jsp application
How to sent mails through jsp application  when i fill the form, and submit it, then a mail should be sent to persons mentioned in the form and i want to conect the jsp page to database
How to sent mails through jsp application
How to sent mails through jsp application  when i fill the form, and submit it, then a mail should be sent to persons mentioned in the form and i want to conect the jsp page to database
How to sent mails through jsp application
How to sent mails through jsp application  when i fill the form, and submit it, then a mail should be sent to persons mentioned in the form and i want to conect the jsp page to database
How to sent mails through jsp application
How to sent mails through jsp application  when i fill the form, and submit it, then a mail should be sent to persons mentioned in the form and i want to conect the jsp page to database
How to sent mails through jsp application
How to sent mails through jsp application  when i fill the form, and submit it, then a mail should be sent to persons mentioned in the form and i want to conect the jsp page to database
multi client mobile chat application
mobile chat application  plz help me for creating wap based mobile chat application in neatbean. or simply multi client mobile chat application
common database jsp file for all the jsp files in the application
common database jsp file for all the jsp files in the application  hi... use of this single jsp file while connecting to database rather than writing connectivity code in all the jsp pages . send me the code for that . thanks

Ads