Issue
I have developed SAPUI5 application and trying to use servlets for implementing some server side functionality. I have taken guidance from this tutorial
I use JQuery ajax call from SAPUI5 controller to Servlet which works fine on my local development environment ( i.e. Eclipse Neon , localhost ).
//Name of servlet is GetUserServlet , mapping defined in web.xml
$.get('GetUserServlet', {
userName : "Hello World"
}, function(responseText) {
alert(responseText);
});
This Ajax call successfully calls servlet (200 status) and Hello World is alerted when I run this from Eclipse on my local machine. Basically I capture in servlet parameter userName value and send back to controller js file
string text = request.getParameter("username");
response.getWriter().write(text );
But when this application is deployed to ABAP server , the Ajax call to servlet throws 404 (not found error) as seen in Network console of Chrome developer tools.
Has anybody deployed SAPUI5 application with servlet functionality on ABAP ?
Is it some path issue ?
Please tell cause of error or hint in direction to solve this issue.
Solution
You are mixing things up a little. The UI5 app is only a front-end component which, in your case, communicates with a backend JEE application (which contains your servlet). I would assume that you are deploying your servlet + UI5 app locally on e.g. a Tomcat instance (or any other web container). You cannot deploy a Java application to the BSP repository.
The page that you have linked from SCN refers to the old ABAP BSP functionality (which is now obsolete; the BSP repository is simply used to store static files of UI5 applications).
The only way in which you could deploy a JEE application (e.g. a WAR) to an ABAP backend is if the backend is in fact a ABAP+Java Netweaver installation. To be honest, I have never personally seen such a system in use. In this case, you don't even need to use the BSP repository, you can deploy the JEE backend (servlets and what ever else) and the static resources (the UI5 app) inside the JEE "Engine" of the server.
Otherwise, if you have only a plain ABAP system, you have the following possibilities:
- Transform your Servlet in an ABAP REST Service or maybe a Gateway Service (depending on what you want to achieve).
- Deploy the application to some external java web container or application server. Communicate with the ABAP backend through either JCo (RFC) or through some other mechanism (SOAP, REST, etc).
- Deploy the application to the SAP Cloud Platform and communicate with the ABAP backend using the SAP Cloud Connector.
Answered By - Serban Petrescu