Reputation: 4267
After years using Spring MVC's controllers on Tomcat and Weblogic I have to create a simple Servlet, without the help of any Framework, to run under JBOSS wildfly 10. I miss a step to make it works under JBoss. Under Tomcat it works.
This is my servlet
@WebServlet("/HelloWorld")
public class HelloWorld extends HttpServlet {
private static final long serialVersionUID = 1L;
...
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter printWriter = response.getWriter();
printWriter.println("<h1>Hello World!</h1>");
}
...
}
My WEB.XML file is empty.
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<servlet>
<servlet-name>hello</servlet-name>
<servlet-class>com.de.simple.HelloWorld</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>hello</servlet-name>
<url-pattern>/HelloWorld</url-pattern>
</servlet-mapping>
</web-app>
When I try to run the servlet under JBoss, I don't get any error. Simply, when I go to http://localhost:8080/simple/HelloWorld I get:
The webpage cannot be found
What is the step I need to implement on Jboss? Thank you
Upvotes: 0
Views: 785