Advertisement

06.19.2003 at 11:44PM PDT, ID: 20654602
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Tomcat Error 404
Tags: tomcat, 404, error
I would like to have Tomcat (4.1.12) bring up a specific custom-page whenever a user tries to access a URL that does not exist on the server. Right now I just get the standard error 404 page. Is this possible?

If it IS possible, could I set it for the entire server, rather than for each "service"/site?

More specifically: I am using Tomcat on one server to serve up multiple domains and websites. Whenever a user types a URL that points to one of these the domains (or sub-domains) but requests a page that does not exist in that website, I simply want him to be redirected to the home page which is always the default page in the root directory on the server.

So if I type www.somedomain.com/support/page1.jsp, and that page does not exist, I want to automatically redirect to:
www.somedomain.com

Start your free trial to view this solution
Question Stats
Zone: Software
Question Asked By: Bohumil
Solution Provided By: fargo
Participating Experts: 5
Solution Grade: A
Views: 252
Translate:
Loading Advertisement...
06.20.2003 at 07:10AM PDT, ID: 8766639

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
06.20.2003 at 02:26PM PDT, ID: 8769796

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
06.23.2003 at 03:09AM PDT, ID: 8780283

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
07.01.2003 at 01:31PM PDT, ID: 8835787

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.15.2004 at 08:14AM PDT, ID: 10833859

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
06.22.2004 at 12:06AM PDT, ID: 11366717

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
06.22.2004 at 02:26AM PDT, ID: 11367370

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
06.22.2004 at 11:36PM PDT, ID: 11376645

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
09.28.2004 at 09:55AM PDT, ID: 12171499

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Handhelds / PDAs
  • Displays / Monitors
  • Components
  • Networking Hardware
  • Peripherals
  • Laptops/Notebooks
  • Storage
  • Servers
  • Desktops
  • New Users
  • Misc
  • Apple
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMWare
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMWare
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Community Advisor
  • Lounge
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • Community Advisor
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
06.20.2003 at 07:10AM PDT, ID: 8766639
Hii,

The best way is to add the following in the web.xml for the context.

  <error-page>
      <error-code>404</error-code>
      <location>/index.html</location>
  </error-page>

U can refer the tomcat 4 documentation for more details on this.

Hope this helps
regards
fargo
Accepted Solution
 
06.20.2003 at 02:26PM PDT, ID: 8769796
Thanks, that was just what I was looking for (somehow I overlooked this in the documentation..)

Just as an additional note:
When I set this up, it initially created a circular reference that kept the browser forwarding constantly between two pages:

my "index.jsp" itself does a forwarding to another page (after checking the version of the browser). Now, the funny thing is that the error page defined in Tomcat comes up, but the URL is still the one of the original page that the user typed in. So the forward tries to forward (which uses a relative link) to another page that does not exist, which calls up the error page (index.jsp) again, which forwards to the non-existent page, etc.

So the solution was to create a page called Error404.jsp in the root of every site and use that as the error page. This page would do a forward to "/index.jsp" as an ABSOLUTE link, so that the URL actually gets replaced.
 
06.23.2003 at 03:09AM PDT, ID: 8780283
Hii,

Thanks and glad it helps. Good that u explained ur experiences well.
regards
fargo
 
07.01.2003 at 01:31PM PDT, ID: 8835787
Hi,

the internet explorer (5.0 and newer I think) will create its own short error message when statuscode 404 is received.
This feature is default on.
To ignore this, i call "response.setStatus(200);" in my error servlet (I use a servlet) to change the statuscode from 404 to 200.


ferdi
 
04.15.2004 at 08:14AM PDT, ID: 10833859
Note that the error document is relative to the webapp path...

so if your webapp has a example.com/webapp/404.jsp page, you don't put /webapp/404.jsp into the web.xml instead you just put /404.jsp

I found this out when I did
"telnet localhost 80" and it told me the actual doco it was returning... when I had set up /index2.html as the error doc.

GET /webapp/asdasd HTTP/1.0
 
HTTP/1.1 404 /webapp/index2.html
Date: Thu, 15 Apr 2004 15:05:04 GMT
Server: Apache/1.3.28 (Unix) PHP/4.3.4 mod_jk2/2.0.2 mod_ssl/2.8.15 OpenSSL/0.9.7c
Connection: close
Content-Type: text/plain
 
Connection closed by foreign host.
 
06.22.2004 at 12:06AM PDT, ID: 11366717
I created a "Failure.jsp" page and placed it in my webapp directory. I then added the error redirection code displayed below to my /tomcat_home/conf/web.xml file.

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

<error-page>
  <error-code>404</error-code>
  <location>/Failure.jsp</location>
</error-page>

</web-app>

When I restart Tomcat and try to access my webapp I get a standard tomcat 404 response, regardless of whether the page I'm trying to access actually exists or not. If remove the <error-page> tags from the web.xml and restart Tomcat everything works fine. What am I missing?  It may be relevant that I'm using the invoker servlet in my configuration. I'm running tomcat in stand alone. Also, I've tried this on both Tomcat 4 and 5 versions with the same result. I also get the same result if I create a simple web.xml file containing the <error-page> tags and place it within my webapps WEB-INF directory. Ideally I would like to redirect all 404 errors to an offsite page as in   <location>http://mysite.com/error.html</location>

Any help is greatly appreciated.

- Rich
 
06.22.2004 at 02:26AM PDT, ID: 11367370
atomicfalls, try putting the codes for redirecting 404 into the webapps/MYWEBAPPS/web-info/web.xml file.

 
06.22.2004 at 11:36PM PDT, ID: 11376645
speculatrix,

The only web.xml file I have resides in /TOMAT_HOME/conf/web.xml. It is the standard file installed with tomcat and the only modifications I have made to it are the addition of <error-page> tags. I have tried putting a web.xml file containing just the 404 codes in webapps/MYWEBAPPS/WEB-INF/web.xml but the result was the same. When I add the <error-page> tags to either web.xml file all requests to the server return a standard tomcat 404 error response indicating that index.jsp was not found on the server. Removing the <error-page> tags and restarting tomcat solves the problem.
 
09.28.2004 at 09:55AM PDT, ID: 12171499
I found that if you want to define a custom error page for all requests you have to define a root webapp in your server.xml file like:

<!-- Tomcat Root Context -->
<Context path="" docBase="MYAPP" debug="0"/>

Then the custom error page for "MYAPP" will be used for requests to contexts that don't exist on the server.
 
 
20080236-EE-VQP-29