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 9136761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:59:44+00:00 2026-06-17T08:59:44+00:00

In the error page I would like to display the URL what the user

  • 0

In the error page I would like to display the URL what the user requested.

In my web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="http://java.sun.com/xml/ns/javaee"
        xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                            http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
        id="WebApp_ID"
        version="3.0">

    <display-name>MyStuff</display-name>

    <error-page>
        <error-code>404</error-code>
        <location>/WEB-INF/error-404.jsp</location>
    </error-page>

</web-app>

This will forward to error-404.jsp, and here is the content of that file:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Page Not found</title>
</head>
<body>
    <p align="center">
    <%
        out.println("Requested resource: " + request.getRequestURL()+ " not found");
    %>
</body>
</html>

The problem it is the request.getRequestURL() need to be changed, but don’t know the keyword for what to search.

When I start the browser for http://localhost:8080/MyStuff then I get the following error:

Requested resource: http://localhost:8080/MyStuff/WEB-INF/error-404.jsp not found

How to solve this?

  • 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-17T08:59:45+00:00Added an answer on June 17, 2026 at 8:59 am

    Here is a simple example of JSP error page that shows the error code and the URL of the requested page:

    404.jsp:

    <%@ page language="java" isErrorPage="true" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
    <!DOCTYPE html>
    <html>
    <head>
        <title>Error page</title>
        <meta charset="utf-8">
    </head>
    <body>
        <button onclick="history.back()">Back to Previous Page</button>
        <h1>404 Page Not Found.</h1>
        <br />
        <p><b>Error code:</b> ${pageContext.errorData.statusCode}</p>
        <p><b>Request URI:</b> ${pageContext.request.scheme}://${header.host}${pageContext.errorData.requestURI}</p>
        <br />
    </body>
    </html>
    

    Useful reading:

    • “JSP.1.4 Error Handling” section in the JavaServer Pages
      Specification (JSR
      245)
      .
    • Handling JSP Page
      Errors
      (from the official Java EE 5 Tutorial)

    P.S.
    The use of scriptlets inside JSP is highly discouraged. Read this post.

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

Sidebar

Related Questions

I would like to use Tomcat's error-page directive to display various different error pages
I would like to set up an error page which will diplay a message
i custom varnish 500 error page,but i found that it could not display chinese
I want to redirect users to an error page if they enter any URL
I want to redirect to error page if the requested URI comes up with
I have a large database of venues - and I would like to display
I am using AJAX to submit a form, and would like to display a
I have a HTML/JQuery frontend. I would like my HTML page to have a
I am setting up a build system and would like to display which task
Im starting to build a new app and I would like to use Backbone

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.