How to run a Java EE project in Tomcat? - java

I have downloaded a jsp/servlet project and want to run it in Tomcat. I have deployed the project in
Tomcat-> webapp
Now on hitting the url in the browser i am getting a 404 error,please tell me what are the steps to run this project?/

To deploy a web application in Tomcat without an IDE just copy the project into Tomcat's webapps folder. Then logon to Tomcat's main page with http:\localhost:8080 with a username and password. This is what you should do normally. Please elaborate on your issue.

You are getting 404, it means your server is up and running, but your url is in correct. Please try the below url pattern :
If your war name is HelloWorldJspExample.war
and jsp file name which you are trying to access is loginPage.jsp
then your url should be
http://localhost:8080/HelloWorldJspExample/loginPage.jsp

Refer this question execute-servlet-program
Hope this will do.

If You are copied a .war file into tomcat->webapps the please hit the
localhost:8080
if you see the home page of tamcat then goto manager and enter username and password and start your application.
if u cant see the tomcat home page please start the tomcat first goto tomcat->bin and click startup.bat file.
and for tomcat username and password please check the tomcat->conf->tomcat-users.xml file for username and password.

Related

Why Tomcat works fine when I put a .jsp but with a .html doesn't works?

I'm working with eclipse and I created a project, I put a test.html and test.jsp file in the root folder. In the URL of the Google Chrome I put this:
http://localhost:8080/project/test.html Error 404
http://localhost:8080/project/test.jsp Works (hello world!)
What is happening?
Double check if your test.html exists under this path:
"Workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\project"
If exists, then it should be accessed normally, if not then you have to clean/build your application correctly or even try to restart eclipse.
Based on your follow-up comments about the custom Tomcat install and the project error message, it sounds like you either don't have Eclipse properly configured to use your Tomcat server, or you don't have your project associated with the Tomcat server you've set up, and so perhaps your changes arent being deployed properly. See if that issue has a quick fix suggestion (right click it) or go through your project settings and verify your selected server runtime. Sorry on phone can't give specific instructions.

How to stop redirecting the URL to localhost

I have installed the tomcat server in windows. I have added the test.example.com string in hosts file so I can access tomcat console using the localhost:8080 and also test.example.com:8080.
Then I deployed a war file in webapps folder. Now, I can access the application using the URL localhost:8080/test and test.example.com:8080/test.
Here, When I access test.example.com:8080/test the URL is redirecting to login page as localhost:8080/test/UI/Login but I want it to be test.example.com:8080/test/UI/Login
Can anyone suggest me how to access with out localhost and without updating the existing war file.

Deploying war file on Vesta CP

I am doing this for the first time. I have a VPS server with Vesta CP installed on it. I did the following -
Created a new Web Domain.
It automatically created entries in DNS
I setup FTP user for myself.
I am able to connect to ftp using Fileszilla.
In filezilla, I can see public_html folder (but NOT .htaccess)
Created WAR file from eclipse for my application.
Uploaded my war inside public_html.
tried - http://myserver_ip/MenuBook/HomePageServlet - in browser. It
said 404 Page not found. (MenuBook is the ContextRoot of my web
application)
Can someone please explain what else do I have to do to make this work. I read that you have to modify .htaccess file too, here - https://documentation.cpanel.net/display/CKB/How+to+Deploy+Java+Applications
But I can not see any .htaccess file through ftp.
Please help. Any help will be greatly appreciated.
you must install web server that support java servlets like tomcat or glassfish ... vestacp by default has no just webservers you must install it your self
you can check this link it may help
https://forum.vestacp.com/viewtopic.php?f=11&t=6977

Deploying .war application in Tomcat to root

My .war application runs on TomCat
I am able to deploy my .war application to a specific directory e.g. www.abc.com/specific
I would do this by renaming my application specific.war and then going to Tomcat Web Application Manager and then going to "WAR file to deploy", select my WAR file and deploy it.
However I would like to deploy it so that if the user types www.abc.com he/she will go straight to the application, without specifying the directory.
How is this possible? Thanks [I have tried calling the application root.war]
Two ways:
name the war file ROOT.war
specify the context path attribute in META-INF/context.xml - see here
I solved this by using forwarding/masking (through the domain name provider)
I forwarded www.abc.com to www.abc.com/specific
and I masked so that "specific" is not shown
I am not sure if this answers your question. But I believe u can automatically navigate to the page u want using the
<welcome-file></welcome-file>
in the web.xml file of ur web app.

Add tomcat server in netbeans

I am using netbeans and when I create a new web application project I click the "Add" to add a server cause in a tutorial they are using tomcat and not glassfish.
I then choose Tomcat 6.0 from the list and the next page is displayed where I have to input
Server Location
Username
Password
I don't get this part.
What location do they mean? And what username and password?
With Server Location they probably mean the root directory of the Tomcat installation, sometimes also known as CATALINA_HOME.
There's a file in Tomcat's conf directory called tomcat-users.xml. The Tomcat documentation tells you to add a user ID and password to this file so you can administer Tomcat. So those would need to be entered in NetBeans then.
Carl's answer is right, but there is a wiki page with instruction on how to register an existing Tomcat installation with NetBeans that is a bit more complete.
Also, the IDE will add the values of user name and password to the tomcat-users.xml for you if the checkbox with the label 'Create user if it does not exist' is selected (and you have write access to the tomcat-users.xml file).

Categories