Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
Component Sharing
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Gagandeep Singh Bhatia
Component Sharing
Commits
d037a259
Commit
d037a259
authored
Jul 02, 2024
by
Sonawane Amol Madhjuar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
3ad1148c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
145 additions
and
0 deletions
+145
-0
Amol/VisionDIJSP/CustomerExtrenalInfo.jsp
Amol/VisionDIJSP/CustomerExtrenalInfo.jsp
+145
-0
No files found.
Amol/VisionDIJSP/CustomerExtrenalInfo.jsp
0 → 100644
View file @
d037a259
<%@ page
language=
"java"
contentType=
"text/html; charset=UTF-8"
pageEncoding=
"UTF-8"
%>
<%@ page
import=
"java.io.*, java.net.*, java.sql.*, javax.naming.Context, javax.naming.InitialContext, javax.sql.DataSource"
%>
<%@ page
import=
"ibase.utility.BaseLogger, ibase.utility.UserInfoBean, ibase.webitm.ejb.DBAccessEJB, ibase.system.config.ConnDriver"
%>
<!DOCTYPE html>
<html>
<head>
<meta
charset=
"UTF-8"
>
<title>
Customer External Information
</title>
</head>
<body>
<%
BaseLogger
.
log
(
"3"
,
null
,
null
,
"Customer Exterranl Info "
);
System
.
out
.
println
(
"...@@@@@@@ In CustExtInfo.jsp @@@@@@@@..."
);
String
custCode
=
request
.
getParameter
(
"CUST_CODE"
);
BaseLogger
.
log
(
"3"
,
null
,
null
,
"CustCode ["
+
custCode
+
"]"
);
UserInfoBean
userInfo
=
(
UserInfoBean
)
session
.
getAttribute
(
"USER_INFO"
);
DBAccessEJB
dbAccess
=
new
DBAccessEJB
();
String
infoResponse
=
null
;
BaseLogger
.
log
(
"3"
,
null
,
null
,
"infoResponse1 :: "
+
infoResponse
);
// Check if custCode is present in the database
String
custCODE
=
dbAccess
.
getDBColumnValue
(
"CUST_EXT_INFO"
,
"CUST_CODE"
,
"CUST_CODE = '"
+
custCode
+
"'"
,
userInfo
.
getTransDB
());
BaseLogger
.
log
(
"3"
,
null
,
null
,
"CustCode present in CUST_EXT_INFO Table ["
+
custCODE
+
"]"
);
if
(
custCODE
!=
null
)
{
BaseLogger
.
log
(
"3"
,
null
,
null
,
"Inside if block.."
);
// If custCode is present, get the INFO_RESPONSE from database
infoResponse
=
dbAccess
.
getDBColumnValue
(
"CUST_EXT_INFO"
,
"INFO_RESPONSE"
,
"CUST_CODE = '"
+
custCode
+
"'"
,
userInfo
.
getTransDB
());
BaseLogger
.
log
(
"3"
,
null
,
null
,
"
infoResponse
::===
>
[
" + infoResponse + "
]
");
} else {
BaseLogger.log("
3
", null, null, "
Inside
else
block
..
");
// If custCode is not present, call the API and store the response in database
try {
String apiUrl = "
https:
//sandboxapi.atlas.vayana.com/AtlasApi/v1.0/aadhaar/udyam/registration/verification";
URL
url
=
new
URL
(
apiUrl
);
HttpURLConnection
conn
=
(
HttpURLConnection
)
url
.
openConnection
();
conn
.
setRequestMethod
(
"GET"
);
BufferedReader
in
=
new
BufferedReader
(
new
InputStreamReader
(
conn
.
getInputStream
()));
String
inputLine
;
StringBuffer
apiResponse
=
new
StringBuffer
();
while
((
inputLine
=
in
.
readLine
())
!=
null
)
{
apiResponse
.
append
(
inputLine
);
}
in
.
close
();
infoResponse
=
apiResponse
.
toString
();
BaseLogger
.
log
(
"3"
,
null
,
null
,
"API Response: "
+
infoResponse
);
// Store the API response in the database
Connection
connection
=
null
;
PreparedStatement
pstmt
=
null
;
try
{
ConnDriver
connDriver
=
new
ConnDriver
();
connection
=
connDriver
.
getConnectDB
(
userInfo
.
getTransDB
());
String
insertQuery
=
"INSERT INTO CUST_EXT_INFO (CUST_CODE, INFO_RESPONSE) VALUES (?, ?)"
;
pstmt
=
connection
.
prepareStatement
(
insertQuery
);
pstmt
.
setString
(
1
,
custCode
);
pstmt
.
setString
(
2
,
infoResponse
);
pstmt
.
executeUpdate
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
finally
{
if
(
pstmt
!=
null
)
{
try
{
pstmt
.
close
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
if
(
connection
!=
null
)
{
try
{
connection
.
close
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
}
}
catch
(
Exception
e
)
{
out
.
println
(
"Error calling API: "
+
e
.
getMessage
());
}
}
%>
<h1>
Customer External Information
</h1>
<%-- Check if infoResponse is not null and parse JSON --%>
<%
BaseLogger
.
log
(
"3"
,
null
,
null
,
"infoResponse2 :: "
+
infoResponse
);
if
(
infoResponse
!=
null
||
!
infoResponse
.
trim
().
isEmpty
())
{
BaseLogger
.
log
(
"3"
,
null
,
null
,
"Inside the If Block :: "
+
infoResponse
);
%>
<h2>
JSON Data
</h2>
<table
id=
"jsonData"
>
<thead>
<tr>
<th>
Key
</th>
<th>
Value
</th>
</tr>
</thead>
<tbody>
<%-- Parse JSON response using JavaScript --%>
<script>
var
jsonData
=
<%=
infoResponse
.
replaceAll
(
"\""
,
"\\\""
)
%>
;
function
createTableFromJson
(
data
,
parentElement
)
{
for
(
var
key
in
data
)
{
if
(
data
.
hasOwnProperty
(
key
))
{
var
value
=
data
[
key
];
var
row
=
parentElement
.
insertRow
();
var
cell1
=
row
.
insertCell
(
0
);
var
cell2
=
row
.
insertCell
(
1
);
cell1
.
innerHTML
=
key
;
if
(
typeof
value
===
'
object
'
&&
value
!==
null
)
{
cell2
.
innerHTML
=
""
;
var
nestedTable
=
document
.
createElement
(
"
table
"
);
var
nestedBody
=
document
.
createElement
(
"
tbody
"
);
nestedTable
.
appendChild
(
nestedBody
);
createTableFromJson
(
value
,
nestedBody
);
cell2
.
appendChild
(
nestedTable
);
}
else
{
cell2
.
innerHTML
=
value
;
}
}
}
}
var
tableBody
=
document
.
getElementById
(
"
jsonData
"
).
getElementsByTagName
(
'
tbody
'
)[
0
];
createTableFromJson
(
JSON
.
parse
(
jsonData
),
tableBody
);
</script>
</tbody>
</table>
<%
}
else
{
%>
<p>
No data available.
</p>
<%
}
%>
</body>
</html>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment