1

Currently I'm developing Java Servlets Application for Student Management System, but currently I need to manage some functions via ESB by Simple REST API calls, could you please provide how to manage Rest API calls in WSO2 ESB Servlets

Melan Rashitha
  • 481
  • 2
  • 13

1 Answers1

1

A WSO2 REST API can be invoked as a simple HTTP call, given all the required payload content and headers, such as HTTP method, Content-Type, etc. Therefore, one way is to implement the API call from the Java side, import the Java class from JSP, and use it accordingly. There are several ways that you can follow to send a HTTP call with Java. This is recommended if you need server side operations to be done with the REST API.

<%@ page import="org.wso2.xxx.JavaClassName" %>
<%
/** Use Java implementation here **/
%>

If you need to call the API for client side processing, you can even send the HTTP call from Javascript using jQuery.ajax, jQuery.post, jQuery.get, etc. For the Javascript implementation, you can import that javascript page from JSP, and call javascript functions as required.

<script type="text/javascript" src="js/js-class-name.js"></script>
<input type="button" value="ABC" name="submit" class="button" onclick="javascript:functionName('<%=value1%>','<%=value2%>');"/>