Solved

Remove webapp from URL & Find redirect

Posted on 2009-04-02
9
1,072 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

 
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

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
site launch date and last modified date 3 109
SQL to update characters in table column 6 175
tomcat startup error 5 174
maven disable workspace resolution 1 78
      Install BugTracker on Windows 2008 server Step 1:  Install windows 2008 server 32 bit OS and configure IIS. Step 2:  Install SQL server ( SQL server 2005 or SQL server 2005 Express edition. The installer for 2008  version isn’t very f…
Thoughout my experience working on eCommerce web applications I have seen applications succumbing to increased user demand and throughput. With increased loads the response times started to spike, which leads to user frustration and lost sales. I ha…
Wufoo.com provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

751 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