Вы находитесь на странице: 1из 4

<html>

<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Database Connect</title>
<script language="javascript" type="text/javascript">
function test_insert1(userid)
{
alert("Hello"+userid);
var jspcall = "http://localhost:9704/insert/Insert.jsp?&userid="+ userid;
alert("jspcall"+jspcall);
window.location.href = jspcall;
}</script>
</head>
<body>
<p>Click the button to for user Access.</p>
<button type="button" onclick="test_insert1(@1)">Try it</button>
<p id="records"></p>
</body>
</html>
===================================================================================
===

<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Database Connect</title>
<script language="javascript" type="text/javascript">
function loadDB(n)
{
alert("hello"+n);
var conObj = new ActiveXObject('ADODB.Connection');
alert("conObj"+conObj);
var connectionString = "Provider=OraOLEDB.Oracle;Data Source=(DESCRIPTION =(ADDRESS
= (PROTOCOL = TCP)(HOST = VMC-OCM-007-D.cisco.com)(PORT = 1521))(CONNECT_DATA
=(SERVER = DEDICATED)(SERVICE_NAME = orcl)));User Id=system;Password=welcome1;"
alert("connectionString"+connectionString);
conObj.Open(connectionString);
var rs = new ActiveXObject("ADODB.Recordset");
alert("rs"+rs);
var sql = "INSERT INTO username(name) VALUES ("+n1+")";
alert("sql"+sql);
rs.Open(sql,conObj);
alert(rs(0));
rs.close;
conObj.close;
}</script>
</head>
<body>
<p>Click the button to for user Access.</p>
<button type="button" onclick="loadDB('@1')">Try it</button>
<p id="records"></p>
</body>
</html>
============================================================
<html>
<head>
<center>INSERT INTO TABLE</center>
</head>
<body bgcolor="bisque" text="green">
<center>
<form name="f" method="post" action="5.jsp">
Enter the name: <input type="text" name="n1"><br><br>
Enter the roll no: <input type="text" name="n2"><br><br>
Enter the marks: <input type="text" name="n3"> <br><br>
<input type="submit" value="insert">
</form>
</center>
</body>

</html>

==========================================================
<html>
<head>
</head>
<body>
<%@page language="java"%>
<%@page import="java.sql.*"%>
<%
String s1=request.getParameter("n1");
int s2=Integer.parseInt(request.getParameter("n2"));
int s3=Integer.parseInt(request.getParameter("n3"));
PreparedStatement ps=null;
Connection cn=null;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
cn=DriverManager.getConnection("jdbc:odbc:j1");
ps=cn.prepareStatement("insert into student1 values(?,?,?)");
ps.setString(1,s1);
ps.setInt(2,s2);
ps.setInt(3,s3);
ps.executeUpdate();
out.println("insertion done");
%>

</body>
</html>
===============================================================
<HTML>
<HEAD>
<TITLE>
Add three numbers
</TITLE>
<SCRIPT>
function addThreeNums (inOne, inTwo, inThree) {
alert("inOne"+inOne);
var inOne = Number(inOne);
var inTwo = Number(inTwo);
var inThree = Number(inThree);
return Number(inOne + inTwo + inThree);
}
</SCRIPT>
</HEAD>
<BODY>
<FORM Name="theForm">
<INPUT Type=Text Name="num1"><br>
<INPUT Type=Text Name="num2"><br>
<INPUT Type=Text Name="num3"><br>
<INPUT Type=Button Value="Add Them"
onClick=addThreeNums(theForm.num1.value,theForm.num2.value,theForm.num3.value)>
</FORM>
</BODY>
</HTML>
===================================================================================
<body>
<h1>Adding 'a' and 'b'</h1>

a: <input type="number" name="a" id="a"><br>


b: <input type="number" name="b" id="b"><br>
<button
onclick="add(document.getElementById('a').value,document.getElementById('b').value)
">Add</button>

<script>
function add(a,b) {
var sum = parseInt(a) + parseInt(b);
alert(sum);
}
</script>
</body>
=========================================
<form>
a: <input type="number" name="a" id="a"><br>
b: <input type="number" name="b" id="b"><br>
<button onclick="add()">Add</button>
</form>
<script>
function add() {
var a = document.getElementById('a').value;
var b = document.getElementById('b').value;
var sum = a + b;
alert(sum);
}
</script>
====================================================
<form action="" onsubmit="additon()" name="form1" id="form1">
a: <input type="number" name="a" id="a"><br>
b: <input type="number" name="b" id="b"><br>
<input type="submit" value="Submit" name="submit">
</form>
<script>
function additon()
{
var a = document.getElementById('a').value;
var b = document.getElementById('b').value;
alert("a"+a);
alert("b"+b);
//var sum = a + b;
return sum;
}
</script>

========================================================
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Database Connect</title>
<script language="javascript" type="text/javascript">
function loadDB(n)
{
var name=n;
var conObj = new ActiveXObject('ADODB.Connection');
var connectionString = "Provider=OraOLEDB.Oracle;Data Source=(DESCRIPTION =(ADDRESS
= (PROTOCOL = TCP)(HOST = VMC-OCM-007-D.cisco.com)(PORT = 1521))(CONNECT_DATA
=(SERVER = DEDICATED)(SERVICE_NAME = orcl)));User Id=system;Password=welcome1;"
conObj.Open(connectionString);
var rs = new ActiveXObject("ADODB.Recordset");
var sql = "Select name from username where name= '"+name+"'";
rs.Open(sql,conObj);
if(! rs.EOF)
{
alert("Please enter valid username");
rs.close;
}
else
{
rs.close;
var insert = "INSERT INTO username(name) VALUES ('"+name+"')";
rs.Open(insert,conObj);
var sq = "commit";
rs.Open(sq,conObj);
}
conObj.close;
location.reload();
rs.close;
}</script>
</head>
<body>
<button type="button" onclick="loadDB('@1')">Submit</button>
<p id="records"></p>
</body>
</html>

=============================================================
http://www.myfaqbase.com/q0001162-Tutorials-Java-JEE-How-to-build-and-test-a-
simple-helloworld-war-web-application-archive-and-deploy-on-a-weblogic-server.html
http://www.developintelligence.com/sites/default/files/assets/learn/installing-
weblogic-81.pdf
http://www.informit.com/articles/article.aspx?p=32085&seqNum=3
http://www.inf.fu-
berlin.de/lehre/WS00/SWT/BEA/documentation/docs51/classdocs/API_jsp.html

Вам также может понравиться