<%@page import="org.json.simple.JSONObject"%>
<%@page import="org.json.simple.parser.JSONParser"%>
<%@page import="java.io.DataInputStream"%>
<%@page import="java.util.Iterator"%>
<%@page contentType="text/html" import="java.sql.*" pageEncoding="UTF-8"%><%
ResultSet rs=null;
Statement st,st1,st2=null;
Connection con=null;
//String phoneVariablesInJSON = request.getParameter("JSONParam");
System.out.println("Url Is Hitting");
String name,phone,email,password,cpassword="";
int contentLength=request.getContentLength();
ServletInputStream sinp= request.getInputStream();
DataInputStream dis=new DataInputStream(sinp);
byte buf[] = new byte[contentLength];
dis.readFully(buf);
String inString = new String(buf);
JSONParser parser = new JSONParser();
Object obj = parser.parse(inString);
JSONObject jSONObjectct = (JSONObject) obj;
name= jSONObjectct.get("name").toString();
System.out.print("JSON is working====> "+name);
phone= jSONObjectct.get("phone").toString();
email= jSONObjectct.get("email").toString();
password=jSONObjectct.get("password").toString();
cpassword=jSONObjectct.get("cpassword").toString();
System.out.print("JSON is working====>"+password);
//String name=request.getParameter("Name");
//String phone=request.getParameter("phone");
//String email=request.getParameter("email");
//String password=request.getParameter("password");
//String repassword=request.getParameter("cpassword");
//String cpassword = (String)object.get("cpassword");
try{
// System.out.println("SSSSSSSSSS==>> "+request.getQueryString());
Class.forName("com.mysql.jdbc.Driver");
//con = DriverManager.getConnection("jdbc:mysql://localhost:3306/bsnlwap","root","");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test_url","root","");
st=con.createStatement();
String q="Select phone from register where phone='"+phone+"'";
rs=st.executeQuery(q);
if(rs.next()){
phone=rs.getString("phone");
out.println("1");
out.println("Already Exist");
}else{
out.println("0");
String q1="insert into register(name,phone,email,password) values('"+name+"','"+phone+"','"+email+"','"+password+"')";
st1=con.createStatement();
int n=st1.executeUpdate(q1);
out.println("2");
}
}
catch(Exception ex){
ex.printStackTrace();
}
%>
<%@page import="org.json.simple.parser.JSONParser"%>
<%@page import="java.io.DataInputStream"%>
<%@page import="java.util.Iterator"%>
<%@page contentType="text/html" import="java.sql.*" pageEncoding="UTF-8"%><%
ResultSet rs=null;
Statement st,st1,st2=null;
Connection con=null;
//String phoneVariablesInJSON = request.getParameter("JSONParam");
System.out.println("Url Is Hitting");
String name,phone,email,password,cpassword="";
int contentLength=request.getContentLength();
ServletInputStream sinp= request.getInputStream();
DataInputStream dis=new DataInputStream(sinp);
byte buf[] = new byte[contentLength];
dis.readFully(buf);
String inString = new String(buf);
JSONParser parser = new JSONParser();
Object obj = parser.parse(inString);
JSONObject jSONObjectct = (JSONObject) obj;
name= jSONObjectct.get("name").toString();
System.out.print("JSON is working====> "+name);
phone= jSONObjectct.get("phone").toString();
email= jSONObjectct.get("email").toString();
password=jSONObjectct.get("password").toString();
cpassword=jSONObjectct.get("cpassword").toString();
System.out.print("JSON is working====>"+password);
//String name=request.getParameter("Name");
//String phone=request.getParameter("phone");
//String email=request.getParameter("email");
//String password=request.getParameter("password");
//String repassword=request.getParameter("cpassword");
//String cpassword = (String)object.get("cpassword");
try{
// System.out.println("SSSSSSSSSS==>> "+request.getQueryString());
Class.forName("com.mysql.jdbc.Driver");
//con = DriverManager.getConnection("jdbc:mysql://localhost:3306/bsnlwap","root","");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test_url","root","");
st=con.createStatement();
String q="Select phone from register where phone='"+phone+"'";
rs=st.executeQuery(q);
if(rs.next()){
phone=rs.getString("phone");
out.println("1");
out.println("Already Exist");
}else{
out.println("0");
String q1="insert into register(name,phone,email,password) values('"+name+"','"+phone+"','"+email+"','"+password+"')";
st1=con.createStatement();
int n=st1.executeUpdate(q1);
out.println("2");
}
}
catch(Exception ex){
ex.printStackTrace();
}
%>