Reputation: 15058
I opened a Maven project in IntelliJ trying to deploy a Java servlet. This is the class I wrote:
import java.io.*;
import javax.servlet.*;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.*;
@WebServlet("/home")
public class SimpleServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.getWriter().write("Hello World");
}
}
and when I do "tomcat7:redeploy", I get a message that build is successful:
[INFO] tomcatManager status code:200, ReasonPhrase:OK [INFO] OK -
Deployed application at context path /JavaCourse [INFO]
------------------------------------------------------------------------
[INFO] BUILD SUCCESS
Now, I want to know what should be the URL address that I have to type in the browser to get the servlet.
I tried localhost:8080/home and I got an error. Can you please help me?
Upvotes: 0
Views: 795
Reputation: 46
Tomcat deployed your application to 'localhost:8080/JavaCourse/', not just 'localhost:8080/'
You should be able to access this particular servlet at localhost:8080/JavaCourse/home
Upvotes: 1
Reputation:
The full URL of a servlet includes the context into which the web application was deployed.
As you deployed it to /JavaCourse
the URL of the servlet is:
http://localhost:8080/JavaCourse/home
Upvotes: 1
Reputation: 1071
It should be localhost:8080/%your_project_name%/home. Not straightly localhost:8080/home.
Upvotes: 1