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(); } %>
Hi,
Is it possible to update this page with out put screen shot.
Hi satyam,
This is all HTML, so you should be able to just open in it in a browser.
Hi Steve,
I am new to react. Actually I am a java developer. I have done this process in eclipse tool by creating dynamic web project. Am I doing correct? If I do this example in node js react js project flow where do i put jsp file and where do i put ojdbc jar file? Can you please tell me the project flow and structure.
Thanks. In advance.
Hi satyam,
Sorry so late. This was a command line example, it didn’t have any Eclipse or GUI development tool associated with it. Sorry 🙁
strings