package org.ow2.jonas.test.versioning;

import java.io.IOException;

import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class TestServlet extends HttpServlet {

    @EJB
    private TestBean bean;

    private static String version = "2.0.0";

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
     *      response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.getSession(true);
        response.setContentType("text/html");
        response.getWriter().println("WAR version: " + version);
        response.getWriter().println("EJB version: " + bean.getVersion());
        response.getWriter().println("Context URL: \"" + this.getServletContext().getContextPath() + "\"");
        response.getWriter().println("Test image: <img src=\"" + this.getServletContext().getContextPath() + "/image.jpg\" />");
    }
}
