Hello!
I started a new job in a company that loves using the word, "enterprise." As such, everything they've written is in Java. I come from a very web-development heavy background, mainly working with LAMP stacks.
Now, up until three days ago I knew nothing about Java other than people used it and that it is a programming language. Googling up on it, the Java language itself seems simple enough. However, when people say, "Java" it seems they are referring to more than just the language, such as the various frameworks and application servers. It's a little over-the-top, and am having some trouble getting up to speed with "Java."
An upcoming project involves me creating an exposed REST API for one of the products. Seems easy enough. However, I have some questions about how to proceed....
I'm working with JBoss AS for the first time; not sure if there's an equivalent in PHP so I can understand what JBoss does exactly, but I suspect there's a "proper" way of doing things. Here's what I was thinking of doing:
1) Created a package with a single servlet, like so:
package com.awesome.myrestapi;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class HiggiltyServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
public HiggiltyServlet() {
super();
}
public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = response.getWriter();
// @todo ideally, do something more RESTfully useful and less vindictive
out.println( "<html><body>HAHA! all ur api requests are belong to us</body></html>" );
out.close();
}
}
2) As you can see, I was thinking of just overriding the service method to serve my REST API requests.
3) Updated my web.xml file accordingly, so that the url-pattern would match "higgilty", thus making my URL endpoint something like....
http://localhost/awesomeproject/higgilty
Now, I feel like I might be doing something wrong. Am I going about this the right way, or am I totally off the mark?
Any help is greatly appreciated.