Answer the question
In order to leave comments, you need to log in
Who can explain this behaviour?
During tomcat startup, I get Hello output in the browser and "I am called" output in the console.
But when I try to call this method through ApplTest like this, I get the output "InboundJaxrsResponse{context=ClientResponse{method=GET, uri= localhost:8080/Testing/register , status=200, reason=OK}}" but no "I am called" is not displayed in the console ..
Logically, if the response is 200, then there should be no problems .. Is there something wrong in the code?
@WebServlet("/register")
public class JerseyDemo extends HttpServlet{
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.getWriter().print("Hello");
System.out.println("I am called");
}
}
public class ApplTest {
public static void main(String[] args) {
Client client = ClientBuilder.newClient();
WebTarget webTarget = client.target("http://localhost:8080/Testing/register");
System.out.println(webTarget.request().get().toString());
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question