I am trying to deploy my hello.war file (Java application) on my tomcat server.
At first I do it from the "Manager App" on tomcat's default page, and it shows off afterwards in the Applications section. (Attached below circled in red)
But when I try to connect to it by clicking on that link (https://ip-address/hello) it gives me a standard "HTTP Status 404 – Not Found" with the description: "The origin server did not find a current representation for the target resource or is not willing to disclose that one exists." (picture below)
I even try putting my hello.war file manually in the server in the appropriate folder location ("/opt/tomcat/apache-tomcat-9.0.33/webapps") and add read, execute permissions to 'others' on the .war file, add user 'tomcat' as the owner of the file, restart the service. But still nothing seems to help and I still get that 404
It means you do not have a default start page in the application. Create index.html
under WebContent
and refresh the page. For testing, you can put any content in index.html
e.g.
<html>
<head>
<title>Hello world</title>
</head>
<body>
Welcome to my application
</body>
</html>
Check this to learn more about it.
--- Posting the following update based on another request (check comments) from OP ---
As I have mentioned in the comment, you need to forward the request to a JSP (e.g. queryResults.jsp) where you want to show the query result. Put the following code at the end in the doGet
method of your servlet:
String nextJSP = "/queryResults.jsp";
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(nextJSP);
dispatcher.forward(request,response);
This code will automatically forward the request to queryResults.jsp
where you can access the query result saved in the request/session object.
Feel free to comment in case of any doubt/issue.