Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9079873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:56:18+00:00 2026-06-16T19:56:18+00:00

I configured a custom error page in my web.xml file, but the image referenced

  • 0

I configured a custom error page in my web.xml file, but the image referenced in the page shows up as a broken link.

The custom error page is just a simple html page:

<!DOCTYPE html>
<html><head>
  <meta charset="UTF-8"><title>401 Error</title></head>
<body>
    <p style="font-size: 200%; text-align: center">HTTP Error 401: Not authorized to view sensitive data.<br/>
    <img src="NoAccessImage.png" alt="401Error"><br/>
    You must log in before viewing the requested page.</p>
</body></html>

This page is stored in an error folder, along with the image file it references.
An Authentication filter is used to throw the 401 error and the page does show up if I attempt to view protected content without first logging in. But the referenced image is missing. If I just drag the file into a web browser, it displays correctly, so I figured this is a question of context. I tried changing the img src tag to "/error/NoAccessImage.png" with no result.

The relevant AuthenticationFilter code is below:

public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {    
    try {
        boolean authorized = false;
        HttpServletRequest r = (HttpServletRequest) request;
        HttpSession session = ((HttpServletRequest)request).getSession(false); 
        String uri = r.getRequestURI();
        if(uri.indexOf("/Login")>0) {
            chain.doFilter(request, response);
            return;               
        }
        if (session != null) {
            String school = (String) session.getAttribute("school");
            if(school != null && school.length()>0 ) {
                authorized = (school.equals(getURISchool(uri)));
            }
        }
        if (authorized) {
            chain.doFilter(request, response);
            return;
        } else {
            ((HttpServletResponse) response).sendError(401, "You must log in to view the schedule.");
        }
    } catch (IOException io) {
        System.out.println("IOException raised in AuthenticationFilter");
    } 
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T19:56:20+00:00Added an answer on June 16, 2026 at 7:56 pm

    The server doesn’t redirect to your error page. It fowards to it. So, if the initial invoked URL is http://localhost/myApp/foo/bar/baz/SomeAction, since you used a relative path for your image, the browser will look for the image in http://localhost/myApp/foo/bar/baz/NoAccessImage.png. You should thus use an absolute path to reference the image (and for all your images, resources and links, in general).

    And since each application has a context path, you must prepend the context path to the URL. That’s what the JSTL <c:url> tag does:

    <img src="<c:url value='/error/NoAccessImage.png'/>" alt="401Error"/>
    

    which will be translated to

    <img src="/myApp/error/NoAccessImage.png" alt="401Error"/>
    

    (myApp being the contect path of your application)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My website is configured to display a custom HTML-page when an error occurs. This
I have custom errors configured in my web.config, but IIS 6.0 is returning the
On my web application, I had configured my web.config file to set customerrors to
We have a lot of web applications, configured using custom sections (in their web.config
I have a website set up that uses a custom 404 error page. This
I have configured an error 500 page with a controller an a view to
My server is configured to send all 404 errors to a custom 404 error
We have set a custom 404 error page in order to display a 'nice'
I've configured a custom weblink field for defect in Rally. And i would like
I configured Second Level Cache using Ehcache in hibernate.cfg.xml ,ehcache.xml.And setting the cache-usage property

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.