Solved

Remove webapp from URL & Find redirect

Posted on 2009-04-02
9
1,066 Views
Last Modified: 2013-12-02
I inherited my company's website which runs off a remote Tomcat server.  It is all Java, which I've been learning well enough, but I don't know squat about Tomcat servers.

Lets say, for anonymity's sake, my site is "frenchfries.com", when someone comes to my homepage they are redirected to "http:www.frenchfries.com/fries/Welcome.do".  I assume that means that "fries" is the name of my WebApp.  The application "fries" resides in the "catalina/webapps/" directory.  Every page that my site hosts is expressed as "www.frenchfries/fries/aboutus.jsp" or "www.frenchfries.com/fries/recipe/index.html".  The WebApp's name is always included.

How do I remove "fries" from the url.  I want to have my pages come up as "www.frenchfries.com/aboutus.jsp" or "www.frenchfries.com/recipe/index.html".

To that end, how do I get the homepage to drop the "Welcome.do" and just load as "www.frenchfries.com"?
0
Comment
Question by:astangelo
  • 4
  • 4
9 Comments
 
LVL 27

Accepted Solution

by:
mrcoffee365 earned 250 total points
ID: 24052070
The most complete answer is to deploy your war as ROOT.war.  See this documentation on configuration settings:
http://tomcat.apache.org/tomcat-5.5-doc/virtual-hosting-howto.html

To get Welcome.do to be your default page for the site, modify the welcome-file-list section of your webapp's web.xml.  Something like:

<welcome-file-list>
    <welcome-file>Welcome.do</welcome-file>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>
0
 

Author Comment

by:astangelo
ID: 24053034
So, if my application is already built as "fries" can I just rename my compiled WAR file "fries.war" as "ROOT.war"?

0
 
LVL 27

Expert Comment

by:mrcoffee365
ID: 24053076
I think so.  Have you tried it?
0
Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

 
LVL 17

Expert Comment

by:Thomas4019
ID: 24054384
When you go to the home page of a site  "www.frenchfries.com". Most servers try to find either an index.html or other server side script that lies in the root directory and then the server returns that page.
0
 

Author Comment

by:astangelo
ID: 24055011
RE: Homepage  -

My <welcome-file-list> sets (in my WIN-INF folder) index.jsp as the only welcome file.

The interesting thing is that there is an "index.jsp" under the main webapp directory (docBase?) and it does try to redirect to the Welcome.do action (my homepage).  BUT this is not the file that actually redirects me.  

You can see the souce of a page you're not at yet by putting "veiw-source:website-url" into the location bar. If I do a veiw-source look-up of my site (eg. "view-source:http://www.frenchfries.com") in my browser, I get the source for a common redirection page: something like  "If you aren't automatically redirected, click here".  The page uses javascript to redirect the page:
eg:  window.location = window.location + "/fries";
My "index.jsp" file does not have any of that text and the redirection syntaxes are different.  It uses the logic strut, <logic:redirect forward="welcome"/>, where "welcome" is is a global forward to "/Welcome.do".

I can even delete the "index.jsp" file and I still get the same source on my view-source look-up.

Any clues as to where this redirection page is located/propagated?

I know this is a seperate question but I do appreciate the help and input.
0
 
LVL 27

Expert Comment

by:mrcoffee365
ID: 24056402
Yes, you should make a separate question.

At least follow up on the questions you asked and were answered.  Have you been able to make a war that responds to the domain without a war name as part of the url?

Have you tried my suggestion for changing the welcome-file-list?  It sounds as if you have not.  Why don't you do that, and see if the behavior is what you want.

Since you are new to Tomcat, you might not be aware that once you put a new war file on the Tomcat server, you will have to reload the war to get your changes.  Or you can stop and start Tomcat, which should do the same thing.

If it does not change to your new version of the war, then you'll have to manually remove the exploded war directory, then restat Tomcat.

Then we can explain the answer to your next set of questions regarding how jsp files work, how redirection works, etc.
0
 

Author Comment

by:astangelo
ID: 24062593
MrCoffee365 ~

I understand your frustration and apologize.  I will move my other questions into new threads.

As to my responding to one post rather than another, the short answer is that doing what you suggested was going to take time and, not having anything to report to you, I put off responding until I did (have something).
0
 

Author Comment

by:astangelo
ID: 24062730
MrCoffee365 ~

Your recommendation worked aces.  I simply took my existing WAR file (eg. "fries.war") and renamed it "ROOT.war".

The question now, which I believe belongs in this thread, is how then do I direct old links to their new counterparts?  Which is to say, if there was a link to "www.frenchfries/fries/aboutus.jsp" how would I get that to automatically link to "www.frenchfries.com/aboutus.jsp"?
0
 
LVL 27

Expert Comment

by:mrcoffee365
ID: 24063329
Cool about the ROOT.war working for you.

>>how then do I direct old links to their new counterparts?  
You don't have links to "www.frenchfries/fries/aboutus.jsp"  right?  It's other sites or search engines which have it?  Because you can fix your own links, I'm assuming.

Apache has directives for handling this sort of thing -- Tomcat doesn't.  You can use URLRewriteFilter http://tuckey.org/urlrewrite/
or HttpRedirectFilter http://www.zlatkovic.com/httpredirectfilter.en.html
or write your own Filter.

Or you could use HTML Meta tags in all your /fries/*.* files to make them all redirect to the correct new url.

I think it might be better to use a filter, and redirect to a page which says "we've moved" which automatically redirects to the new site after a few seconds (for reading the "we've moved" text).

Or put a custom 404 error in for all pages in /fries (that webapp doesn't really exist any more, right?) that says "we've moved".
0

Featured Post

Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Java concurrency in pictures ( or animations ) 1 128
Search on a site 5 112
ejb on wildfly 5 30
Disable TLS1.0 on Win 2012 server 7 25
If I have to fix slow responding website my first thoughts are server side optimizations: the database may not be optimized or caching is not enabled, or things like that. We often overlook another major part of our web application: the client. We o…
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question