Cannot get Hello World in localhost using Tomcat - tomcat9

I cannot get Hello World page on localhost.
I have ran tomcat and get Apache home page on localhost: 8080. In IntelliJ I have created a new Maven project from archetype web-app. I have added configuration Smart Tomcat. Here, there is an un-editable (grey) field called Tomcat Server with value null.
What should I do to get a web page with hello world? Should i create or edit any files?

Read this: https://tomcat.apache.org/tomcat-7.0-doc/appdev/sample/
You might just forgot to add the path to the URL.
You can try this to: https://tcserver.docs.pivotal.io/3x/docs-tcserver/topics/tutwebapp.html
Hope it helps!
Brhaka

Related

Having Trouble Configuring Tomcat 9 with Eclipse Photon

So I installed Apache Tomcat 9 on my computer, and am having trouble configuring and running it on Eclipse Photon. When I start the server through the Monitor Tomcat application, I can open it up to see the appropriate Apache Tomcat Page, however when I try to run it through eclipse, I get an Error 404, as shown on this image:
I tried changing the server location from "use workspace metadata" to "use tomcat installation", as I saw on several websites and videos to correct the exact issue I'm having ("The origin server did not find a current representation for the target resource or is not willing to disclose that one exists."), but when I run the file after saving that configuration, I get the error as shown in this image:
I am not attaching an application to it just yet, I wanted to ensure that the server was running, and I could see the appropriate Apache Tomcat splash page when I try to access localhost:8080, but that isn't happening.
The Monitor Tomcat application deploys a root application to handle '/'. When Eclipse launches Tomcat for you, it does not deploy anything you do not explicitly tell it to, so nothing's there for '/'.
https://wiki.eclipse.org/WTP_Tomcat_FAQ#If_I_start_my_Tomcat_server_and_try_to_display_Tomcat.27s_default_page.2C_why_do_I_see_a_directory_listing_or_404_error_page.3F
After doing some digging, I discovered that the reason I was receiving those errors was because the entire Tomcat 9.0 file had restricted access, only administrator-level accounts could modify those files. I was able to resolve the issue by going into the file path, right-clicking on the "Tomcat 9.0" folder --> Properties --> Security --> Edit --> Users --> Full Control.

Apache Tomcat 7.0 not working properly with eclipse EE juno version

When I run apache tomcat 7.0 alone, it works without any flaw in my browser I can execute the examples also, but when I apache tomcat 7.0 in eclipse I'm getting a 404 error message saying that "requested resource is not available".
I just type the session example program and run it again, it shows this 404 error message only.
How do I resolve it?
I don't know whether it's the problem with tomcat or with eclipse..
Please help!!
I think your eclipse is configured to load a webapp folder that is not the one installed with tomcat, please follow the steps below:
Open the Run Configuration of the Tomcat 7 in the eclipse
Go to the Arguments tab
In the VM arguments, it should have a property listed: -Dwtp.deploy=...
The folder on this property define the webapp folder for the tomcat started from the eclipse
If you want it to load the tomcat examples, change the folder of that property to the one that have the examples
try doing the following steps:
Eclipse forgets to copy the default apps (ROOT, examples, etc.) when it creates a Tomcat folder inside the Eclipse workspace.
Go to C:\apache-tomcat-7.0.34\webapps,
R-click on the ROOT folder and copy it.
Then go to your Eclipse workspace,
go to the .metadata folder, and
search for "wtpwebapps".
You should find something like
your-eclipse-workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps (or .../tmp1/wtpwebapps if you already had another server registered in Eclipse).
Go to the wtpwebapps folder, R-click, and paste ROOT (say "yes" if asked if you want to merge/replace folders/files).
Then reload tomcat test pagea to see the Tomcat welcome page.
I feel your pain. I am also using Tomcat 7.0, and I've gotten servlets to work in Tomcat doing everything by hand. Then a couple of days ago I downloaded eclipse, and after a struggle I successfully got some servlets to work in eclipse.
I downloaded the Java EE version of eclipse here:
http://www.eclipse.org/downloads/
And then I followed this tutorial:
http://www.vogella.com/articles/EclipseWTP/article.html
The tutorial is a little out of date, but I managed to get eclipse setup correctly using that tutorial. In a couple of places, the tutorial says to click on Window->Preferences->..., which for me was equivalent to Eclipse->Preferences->.... The biggest problem I had was when the tutorial said:
Create a new package called ....
There were no instructions on how to create a new package. The way you create a new package is by looking in your project folder for:
--JavaResources
--src
Then right click on the src folder and select:
New-->Package
Send me a comment if you have any questions about any of the steps in the tutorial.
I got that 404 Error constantly until I figured out what was the correct path with which to call the servlet. If you are calling the servlet, say with a <form>'s action attribute, the url should look like this:
<form action="/<project name>/WelcomeServlet" method="get">
And that would correspond to a web.xml something like this:
<servlet>
<servlet-name>WelcomeServlet</servlet-name>
<servlet-class>com.exmaple.WelcomeServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>WelcomeServlet</servlet-name>
<url-pattern>/WelcomeServlet</url-pattern>
</servlet-mapping>
Are you using servlets 3.0 or 2.5? With 3.0 you use the syntax:
#WebServlet("/WelcomeServlet")
public class WelcomeServlet extends HttpServlet {
for the url mapping instead of a web.xml file.
I had a similar issue with my project.
Maybe Eclipse forgets to copy the default apps (ROOT, examples, etc.) when it creates a Tomcat folder inside the Eclipse workspace.
Go to webapps directory inside apache directory (for example C:\apache-tomcat-7.0.34\webapps), right click on the ROOT folder and copy it.
Then go to your Eclipse workspace, go to the .metadata folder, and search for "wtpwebapps".
Start the Tomcat server by eclipse.
You should find something like your-eclipse-workspace.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps (or .../tmp1/wtpwebapps if you already had another server registered in Eclipse).
Pay attention that the folder tmp0 is present only if the server is started.
Go to the wtpwebapps folder, right click, and paste ROOT (say "yes" if asked to override folders/files).
Then try to see the Tomcat welcome page.
Bye
Monica
Doubleclick the Tomcat server entry in the Servers tab, you'll get the server configuration.
At the left column, under Server Locations,
select Use Tomcat installation radio button ,browse Server Path of the Tomcat Root directory(Ex: D:\RaviTeja\installed\apache-tomcat-7.0.57) and browse Deploy path aslo webapps folderof tomcat
(Ex: D:\RaviTeja\installed\apache-tomcat-7.0.57\webapps).
This way Eclipse will take full control over Tomcat, this way you'll also be able to access the default Tomcat homepage with the Tomcat Manager when running from inside Eclipse.
3. Please find below Tomcat configuration screen shot.

Tomcat webapps directory in windows

I am right now using eclipse to develop a simple web application and I am using Tomcat as web server. I have configured Tomcat in Eclipse and my application runs fine.
My question is: where does Tomcat store the web app and in which folder does it store the classes? I wanted to check the JSP to servlet conversion and wanted to verify how that converted file looks like and I am trying to find where exactly Tomcat stores the web app. I went into the webapps folder where Tomcat was extracted but my webapp is not in that folder.
Can someone tell where I can find the converted JSPs?
right-click on the web project and select Run As then Run Configurations...
From the Arguments tab, the tomcat deploy path is provided as a VM argument with the name -Dwtp.deploy
Found out the location.
Double clicked on tomcat server inside eclipse and got the server path. something like this ..
C:\EclipseWorkspace.metadata.plugins\org.eclipse.wst.server.core\tmp0
The location of the web app will be in the .metadata folder inside eclipse workspace (chk server path) and the converted jsp files can be found in location as given below.
serverpath\work\Catalina\localhost\loginApp\org\apache\jsp
#Admins ... This question can be closed or what ever action needs to be taken.
Thanks.

Difficulty to run simple GWT application

I am making gwt application as following step:
Firstly I install gwt plugin in my eclipse(Helios).
Create dynamic project.
Add gwt plugin through
going to property page of the project
Select google-webtoolkit
check "use GWT"
then go to google-web application
the directory name to "web-content".
Create gwt module in my project then create entry point class then html.
Create a button in onModule method of entry point class.
Then I run the application in tomcat server by just right clicking on project and selecting run as web application(run with tomcat server). As result of this I am getting a blank page on browser? There is no excption in server log. I am not able to debug. Where I am going wrong?
Please help me to sort out this problem.
I am not using google web application because I was getting difficulty to create war file. As a result of this I got the above process to develop GWT application.
Thanks
Rahul
why don't you try in reverse:
First install gwt plugin in my eclipse(Helios).
Create GWT project
Add Dynamic web plugin
going to property page of the project
project Facets tab
Select Dynamic Web Module and java
ok to apply changes.
Write your code
and try to run on server. it will work.

.war file not getting deployed on tomcat server 7.0

I have two queries which I am detailing below:
I installed tomcat 7.0 on my ubuntu machine 11.04.
1. .war file not deployed
When I start tomcat through terminal it works fine and I am able to see the tomcat webpage at http://localhost::8080/. After that I try to deploy a war file ps.war which I copy into the webapps folder inside the tomcat installation directory. And then I restart the server but get the same 404 error even when the .war has been extracted to a ps folder by tomcat.
2. Not running through eclipse
when I open it through eclipse then it shows in eclipse console that the server is started and synchronized but does not run any service and give HTTP 404 eroor. Also in this case, When I open a browser window then I get same 404 error at http://localhost::8080//
Please help me put as I am quite stuck at this moment and not able to run the web services any further. Thanks in advance.
#ezile i can understand for the first query that .war file was faulty thats why you were unable to get it through the browser..
but for second query solution how can i accept that making a correct .war file made http://localhost:8080 running in eclipse...
I am asking this question as i am having the same (first and second) difficulty !!
Did you mean to have two colons in your URL before the port number? It's supposed to just be one. http://localhost:8080
Next, in your tomcat installation directory there is a directory called logs which contains a few log files which will provide more information than just the 404 message you see in your browser.
One other thing to check which we've ran into before is case. I have seen a problem with WebContent\WEB-INF being the wrong case (i.e. lower case) and Tomcat not wanting to pick up the war artifacts.
Thanks all for your responses. I solved the problem. For first part there was some problems with my .war file and thats why it was not getting deployed.
For second, after I corrected my war, it automatically started working for eclipse too.
In my case it was because the WAR required a full path.
I had specified localhost:8080/WarFileName
Which didn't work. It was only when I specified
localhost:8080/WarFileName/src/homepage
Which was how the packages were created in the war file, that it worked.