React JS example with web service call

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

  1. satyam
    March 17, 2017 at 2:39 PM

    Hi,
    Is it possible to update this page with out put screen shot.

  2. March 17, 2017 at 3:15 PM

    Hi satyam,

    This is all HTML, so you should be able to just open in it in a browser.

  3. satyam
    March 21, 2017 at 1:46 AM

    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.

  4. March 29, 2017 at 3:22 PM

    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 🙁

  5. muralikrishna kudupudi
    May 30, 2017 at 10:00 PM

    strings

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.