-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathinsertdata.jsp
More file actions
91 lines (81 loc) · 2.43 KB
/
insertdata.jsp
File metadata and controls
91 lines (81 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<%@ page language="java" import="java.sql.*" pageEncoding="ISO-8859-1"%>
<%@ include file="login.jsp"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String newtblfields=request.getParameter("newtblfields");
String db=request.getParameter("db");
String table=request.getParameter("table");
boolean f=false;
String query="";
if (request.getParameter("col1")!="")
{
for(int i=1;i<=Integer.parseInt(newtblfields);i++)
{
if (request.getParameter("col" + i)!= "" )
{
if (query=="")
{
query= "\"" + request.getParameter("col" + i ) + "\"";
}
else
{
query=query+ ",\""+ request.getParameter("col" + i) + "\"";
}
}
else
{
f=true;
break;
}
}
if (f==false)
{
query=" values("+ query;
query=query+")";
PreparedStatement pstm = con.prepareStatement("USE " + db);
pstm.execute();
pstm = con.prepareStatement("INSERT INTO " + table +query);
pstm.executeUpdate();
}
}
else
{
f=true;
}
%>
<jsp:include page="tabledata.jsp"/>
<%
if (f==false)
{
out.println("<br>");
out.println(" ");
out.println("INSERT INTO " + table +query);
out.println("<br>");
out.println(" ");
out.println("1 Row Inserted");
}
else
{
out.println("<br>");
out.println(" ");
out.println("Some fields are empty");
}
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>Insert Data</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body bgcolor="#f5f5f5">
</body>
</html>