Quick servlet

All

Intro

Gonna show how to do a small servlet here.

Writing

Basically the main part is to extend HttpsServlet

public class StarterServlet extends HttpServlet {

private static final long serialVersionUID = 1L;

@Override
public void init(ServletConfig servletConfiguration) throws ServletException {

super.init(servletConfiguration);

System.out.println(“SERVLET STARTED!”);
}

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

System.out.println(“DOGET!”);

PrintWriter printWriter = response.getWriter();

printWriter.println(“Hello world”);
}
}

Creating the war file

jar -cvf myapp.war *

Deploying

cp myapp.war /home/fdemeloj/jboss-eap-7.3/standalone/deployments

Accessing it

http://127.0.0.1:8080/myapp/starter

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s