How to set custom JSP project url to default url on using tomcat8 local server? - tomcat8

I setup Tomcat8 and upload jsp project in webapps directory.
Now I can visit my site with the url like "http://sitename/project name/web".
But I hope my project to show when visit "http://sitename".
I tried to find solution but nothing is helpful.
Please help me.
Thank you.

Try making the directory named ROOT in webapps directory and put into your jsp file and rename to index.jsp.
If you create ROOT directory or ROOT.war in webapps directory, then the application can be accessed without /[context-name], like "http://sitename/your.jsp".
In addition, Tomcat regards index.jsp as the welcome file by the following default settings in conf/web.xml:
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
So you can access to ROOT/index.jsp by requesting to "http://sitename".

Related

How to configure apache tomcat to point to my project?

I have apache tomcat running into a specific server and I've deployed a project named where2go. So I have a file named:
where2go.war and I deployed this one.
Right now when I try to access this link:
where2go.ca is going to no where and you get a blank page.
If I want to access the project I need to go to:
where2go.ca/where2go
How do I configure my server to show where2go project when I access where2go.ca?
If I understand right your question, you want to put your project on the root of the server and call it like the following: where2go.ca/ instead of where2go.ca/where2go/
If so, in order to achieve that, you need to modify your server.xml (you can find it in the tomcat configuration folder.
Open the server.xml file using your favorite text editor, and add the following directive the file, before the </Engine> directive
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">
<Context path="" docBase="where2go" reloadable="true" override="true"></Context>
</Host>
The above will change your server root path to your project folder.
This change is good when you don't have other project deployed on the same server.
Another solution (to my opinion less preferable) is to manually deploy your project into the ROOT folder inside your /webapps folder.
Hope it will help,
Liron
After looking a while I found the solution on this link:
How can I remove the application name from a Grails application’s URL?
I used the first method:
first shutdown your tomcat [from the bin directory (sh shutdown.sh)] then you must delete all the content of your tomcat webapps folder (rm -fr *) then rename your WAR file to ROOT.war finally start your tomcat [from the bin directory (sh startup.sh)]

Tomcat Webapp Won't Launch

Im new to tomcat and I'm having issues launching my tomcat webapp.
I have tomcat setup on localhost:8081 and the tomcat main page comes up if I put localhost:8081 in the address bar after launching launch-tomcat.bat
I've been stuck on this issue for a week now so I'm going to try and provide as much information as possible. Please let me know if you needed any other additional information.
Any help is greatly appreciated.
If I try to go to http://localhost:8081/week12app_novak/
I get the following error.
Here's a screenshot of the directory path to the webapp.
Also here's a pastebin of catalina.2015-11-22.log http://pastebin.com/U2Dqjqhc
launch-tomcat.bat
setlocal
SET TOOLS_HOME=C:\projects\tools\
SET TOMCAT_HOME=tomcat\apache-tomcat-8.0.14-windows-x64\apache-tomcat-8.0.14
::SET CATALINA_HOME=D:\tools\java\tomcat\apache-tomcat-8.0.14-windows-x64\apache-tomcat-8.0.14
::SET CATALINA_HOME=C:\projects\tools\tomcat\apache-tomcat-8.0.14-windows-x64\apache-tomcat-8.0.14
SET CATALINA_HOME=%TOOLS_HOME%%TOMCAT_HOME%
SET JAVA_HOME=C:\Program Files\Java\jdk1.8.0_65
:: Start Tomcat
%CATALINA_HOME%\bin\startup.bat
endlocal
UPDATED IMAGE AFTER ADDED CODE TO WEB.XML
You didn't post your web.xml, but it probably does not have a welcome file list. If you don't supply one, Tomcat will look for index.html, index.htm, or index.jsp in the week12app_novak directory when you try to access http://localhost:8080/week12app_novak/.
You could rename user-accounts.html to index.html. Or you could add a welcome-file-list tag block to your web.xml.
<welcome-file-list>
<welcome-file>/user-accounts.html</welcome-file>
</welcome-file-list>

Displaying homepage with Pubby / Apache Tomcat

Does anyone know how to go about displaying a custom homepage when Pubby is the root of Apache Tomcat?
My current setup is \Tomcat 6.0\webapps\ROOT\ <- Pubby folders WEB-INF and static are in this folder.
Whilst creating custom pages for e.g. localhost:8080/About is completely fine, (I just create a folder within my webapps folder called "About", and put my index.html in there), I don't how to get a custom index.html to display when I navigate to localhost:8080
I've tried sticking index.html files across my directories, but localhost:8080 won't resolve to any of them.
Thank you!
The index files for http://localhost:8080/ will be defined in $CATALINA_BASE/webapps/ROOT/WEB-INF/web.xml with defaults taken from $CATALINA_BASE/conf/web.xml
Assuming the ROOT app does not specify any welcome pages then an index.html placed at $CATALINA_BASE/webapps/ROOT/index.html should do the trick.

Running jsp files from /srv/http using Apache HTTP server and Tomcat

I'd like run jsp files directly from /srv/http without deploying them the Tomcat-way. For example, I want to be able to create symbolic link to my webapp directory (e.g. /home/user/myapp/) in /srv/http and access some app's page through http://localhost/myapp/page.jsp.
Is this possible and how would I set this up?
NOTE: This is not for production. We have to use JSP at university and I want to be able to quickly test my pages.
Open the server.xml of your Tomcat. Assuming if your are using Tomcat 6.x+ then it would be at /tomcatDir/conf/server.xml.
Make an entry with your path
<Context path="/myapp" docBase="yourPathGoesHere" debug="0" reloadable="true" />
Restart Tomcat if already running.
What I did at the moment was creating a symlink in /var/lib/tomcatX/webapps to my project path. This is not the answer I was looking for though, but it is a way to deploy an app without much work.
(X in the above path means your Tomcat version)
If you set <Host name="localhost" appBase="/srv/http"> then all of the directories in it will be deployed as web applications.
If you want /srv/http to be the ROOT application/directory add a file: tomcat/conf/Catalina/localhost/ROOT.xml
with the Context docBase="/srv/http", rather than adding a Context definition to server.xml - this has been strongly discouraged for years.

Apache tomcat deployment

I have a war file which is a simple dynamic web application where I will call a JSP file which calls a Java file and does some stuff. There is no servlet programming involved.
I deployed the war file in the webapps folder of the tomcat folder.
I restarted the server, the application is extracted and when i call the jsp file like below it is working like a charm.
localhost:8080/Login/login.jsp
But i want to create a directory structure in the webapps folder and place the war file in it and access it as follows
the directory structure is
<tom cat folder>webapps/myapp/mylogin/<my war file>
what i did was copied the extracted war file from the webapps folder and pasted it in the above directory structure
When i accessed it like below it is throwing error
localhost:8080/myapp/mylogin/Login/login.jsp
Please let me know how to host my war file with directory structure in webapps folder.
Hope i was clear in my question.
That should work. What is the error in the log files (access log file, stdout/stderr) and on the screen ?
I need to make a mapping in the server.xml file.
<Host name="showcase.com" appBase="webapps/myapp/mylogin/"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
</Host>