How to servlets from ember

I am using java servlet for back-end. How do i call those servlet methods from ember?

Hi @Dhanabal, I assume this is an HTTP servlet? And you are defining HTTP methods GET/POST/etc? If so then you can make requests to the backend in a number of ways. First you have to decide where to make requests from. Typically GET requests would be made from an ember route using fetch or using Ember Data.

For many CRUD type applications Ember Data will be the easiest way to start out, but it depends a bit on your use case. I’d recommend reading over the guides sections on Routing and Ember Data for starters. And of course if you have any specific questions along the way ask here or in the Ember Discord community. Good luck!

1 Like

Thank you @dknutsen. How do i deploy my ember project in tomcat?

At a high level it would look like this:

  • Run ember build -e production (assuming you want to build for production)
  • Ember will build your app (which basically smashes all your app source and all your vendor source together into a few files and links them into index.html) and place it in <projectroot>/dist
  • Once that happens you have a built app which is just static files, so any static file server will be able to serve your Ember app. You simply need to place those files in the correct spot and configure your server appropriately.
  • One thing to note is that unless you’re using locationType “hash” you will need to tell Tomcat to do URL rewriting so it delegates ember routes to the ember app instead of trying to serve them itself. This applies to any single page application on any server. Here is a recent thread in this very board about configuring Tomcat that way. Unfortunately I can’t be a ton of help with that because I’m not super familiar with Tomcat in recent years.

Anyway, hope that helps with the basics at least. There’s a neat addon called ember-cli-deploy with a bunch of plugins that can help in a variety of deployment scenarios. I’m not sure if there’s anything that would specifically help with Tomcat deployment but it might be worth looking into once you have the basics working if you want more automated deployment.

1 Like

I’m not totally sure what you’re asking, or what a servlet filename is. When an Ember app is built it is squashed into some js and css files, and an index.html page, which would be the page you want to serve.

But if by servlet filename you mean something related to servlet implementation details that doesn’t have any bearing on Ember so you can call it whatever you want. Ember doesn’t care about your backend at all beyond using HTTP/sockets/etc as a communication interface.