How to Remove Project name from eclipse url? - java

Basically I want to remove project name while I access my project in eclipse.
so currently when I want to access a link of my web-app I have to put it as localhost:8080/project_name/blah_blah_blah
But I want it accessible by just localhost:8080/blah_blah_blah
or say The project itself should be accessible by just localhost:8080
.
Through googling I found this URL issue with tomcat include project name but in my case my context root is as / by default.
Project Context root Options
FYI: This is the only project I have in my Eclipse

For people who come across this problem too.
To explain deeply: First remember that eclipse uses server under eclipse project explorer within its all configuration.
In order for you change your project path to something different, what you can do is to open server.xml under Project Explorer -> Servers -> Tomcat vX.X ... -> server.xml.
At the bottom of this file You should see this line Before End of </host Tag:
<Context docBase="Duck" path="/Duck" reloadable="true" source="org.eclipse.jst.jee.server:Duck"/>
Notice: My project Name is Duck.
Now in order for you to access your web-app without project name replace path="/Duck" to just path="/" or You can set it to any name you want.

Related

Run the website on server on eclipse ide with tomcat as server

I have made a website using Tomcat Server on Eclipse Mars 2.0 IDE. When I run it on server, I have to manually add the name of the first (home) page of the website i.e the JSP/HTML file.
I want the website to open directly on the server so tell me how to do that please.
If you put an index.html into src/main/resources/static/ and reload the server does it show the content of the index page? If you have no static folder then go ahead and create one :)
In general you have to decide for a context-root which is basically the name of the application. If the name of the application is 'myapp' and the context-root is set to 'myapp' too then you should be able to see the website at serverip:port/myapp/.
If your project is configured as a WebProject you should be able to see Web Project Settings in the properties of the project itself. There you can adjust the context root. If you leave it empty it means that your application will be reachable at serverip:port/.
you can change your welcome-file-list in web.xml
you can refer this
https://cloud.google.com/appengine/docs/flexible/java/configuring-the-web-xml-deployment-descriptor
or look for Configuring the web.xml deployment descriptor

Tomcat : Context path not being set

I have a web app set up and running on Tomcat 8 with the project WAR file in the webapps folder in the tomcat directory. If i use any of the following links my project works fine
http://localhost:8066/myWebApp/home/
http://localhost:8066/myWebApp/booking/
http://localhost:8066/myWebApp/contactUs/
i want to set it so the above URL's work but also the following URL's which have /app added after the project name
http://localhost:8066/myWebApp/app/home/
http://localhost:8066/myWebApp/app/booking/
http://localhost:8066/myWebApp/app/contactUs/
i have set the path in the context.xml file as seen below
<Context docBase="myWebApp" path="/app" reloadable="true"> ... <Context>
but this does not work. am i doing this wrong or how can i go about doing this?
EDIT :
I can do this in eclipse by going to the server tab, opening the server and looking in the modules tab, so how do i do this on the Tomcat itself
You maybe use UrlRewriteFilter:
1. Add dependence
2. Change web.xml
3. Set rule in WEB-INF\urlrewrite.xml
or Rewrite.

How to setup JNDI resource in tomcat with IntelliJ IDEA

I'm new to IntelliJ IDEA and I'm trying to set up JNDI resource in Tomcat but I'm using intelliJ IDEA. I have done this with Eclipse many times, but as you know there is a separate folder Servers in the project structure that allows you to open the server.xml and set up the JNDI resource. I've looked through the options of Tomcat in IDEA but couldn't find anything. Could you please help me?
You can just edit server.xml file in TOMCAT_HOME/conf/ directory, where TOMCAT_HOME is the directory of the Tomcat installation you have configured in Run/Debug configuration.
You can open and edit that file in IntelliJ using File/Open or just edit it outside of the IDE using vim for instance.
Project Structure > Module > Web > Click -> Add Application Server
specific descriptor... > Click Tomcat Server > context.xml will make

Eclipse & Tomcat: How to deploy a project to differently named directory

I am using Eclipse Juno. I'd like to know how, if possible, to deploy a workspace project ('Foo') to a folder under Tomcat called 'Bar'.
Some points to note:
Project name in eclipse: Foo
Folder that gets created when I publish: $TOMCAT/wtpwebapps/Foo
Folder that I wish to be created: $TOMCAT/wtpwebapps/Bar
I have set the 'Context Root' under 'Web Project Settings' to Bar
The project has the 'Dynamic Web Module' facet applied.
I am not asking about the way in which I would access this project via the webserver (ie., http://localhost:8080/Foo vs http://localhost:8080/Bar). I explicitly mean the name of the folder to which the content is deployed.
MyEclipse is able to do this. I don't want to use MyEclipse, so would love to know how to achieve this using the vanilla version.
Thanks in advance!
Open the project's Properties dialog (either from its context menu or the main Project menu with that project selected) and change the context root on the Web Project Settings page.
You can write a script which copy your /desired_folder to your desired_directory and call that script in your code at the end or somewhere in eclipse properties after compilation or execution.It may works fine

How to make the application context run as root in Spring 3 MVC and eclipse

I’m trying to develop a Spring 3 MVC application using the Springsource Tool Suite/Eclipse IDE.
My current application context in STS/Eclipse is /localhost:8080/realtyguide/
What I want is to access the application as root using just /localhost:8080/
I tried in eclipse.. Project > Properties > Web Project Settings > entered “/” for Context Root . But this just returned a “404 error - requested resource (/) is not available” after executing the app. And it also broke the app. So I just put context root back to 'realtyguide'.
I deployed the app to my webhost on a Tomcat server. I edited the server.xml’s and elements and so I was able to bring up the index page with the url www.mydomain.com.
However, the links to the other pages are broken. It is also not picking up the static resources for the index page like css and jquery files.
I believe this is caused by my app’s application context of /localhost:8080/realtyguide/ in eclipse (in my development pc). The rest of the pages returned by my controller has a url of /localhost:8080/realtyguide/page_name
How do I change my app’s application context to run as root in eclipse, as in simply /localhost:8080/. So that my pages would be called as simply /localhost:8080/page_name
Is the solution a setting I should make in my web or Spring configuration files or in eclipse?
I’ve tried googling this but have not found a clear, definitve answer. I am very new to this and a detailed answer from you will be of great help.
Thanks to the other answers provided. However, it doesn't address my main objective - to run the app as root inside eclipse.
This is how I was able to do it. I changed Tomcat's conyext path in eclipse.
Do the following:
Right click on the server name from the Server Console > Open
Click on the Modules tab
Click on a module then click the Edit button
Edit the entry for Path to the desired context path then click
OK
You need to make your web-app the "default" application, ROOT. There are step-by-step instructions on the Tomcat Wiki, at http://wiki.apache.org/tomcat/HowTo#How_do_I_make_my_web_application_be_the_Tomcat_default_application.3F.
One way is to name the war simply ROOT.war (uppercase).
This works only if you deploy not from eclipse
If you have done your links/urls with <c:url> or <spring:url> then it should work without problems.
Simply change server.xml in Tomcat Server.
Package Explorer > Servers
expend path Tomcat vX.X Server
open server.xml
go to Server > Service > Engine
find your Context and change path to value "/"
restart the server!

Categories

Resources