This is a simple example of using React JS to call a web service (simple web page in our example). Of course, a true web service would normally be the source of the data, this is just a simple example to show the call.
The example queries the database for the newest record timestamp every five seconds, and renders the value…
React Service Call Test
…with the service/web page below…
<%@page contentType="text/plain"%>
<%@ page import="java.sql.*" %>
<%
Connection con = null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
con = DriverManager.getConnection("jdbc:oracle:thin:user/password@host:1521/service");
PreparedStatement pst = con.prepareStatement("select max(submitted_date) from orders where submitted_date >= sysdate - 5/1440");
ResultSet rst = pst.executeQuery();
while (rst.next()) {
out.println(rst.getString(1));
}
}
finally {
con.close();
}
%>
5 comments for “React JS example with web service call”