Java Servlet Error Page Handle


web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
    <welcome-file-list>
        <welcome-file>fi_login.jsp</welcome-file>
    </welcome-file-list>
    
    <error-page>
        <error-code>404</error-code>
        <location>/accessDenied.jsp</location>
    </error-page>
    <error-page>
        <error-code>500</error-code>
        <location>/accessDenied.jsp</location>

    </error-page>
</web-app>

fi_login.jsp

<%-- 
    Document   : gl_login
    Created on : Aug 27, 2016, 8:37:47 PM
    Author     : Pukar
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Filter</title>
        <style type="text/css">
            *{
                font-family: arial;
                font-size: 15px;
            }
        </style>
    </head>
    <body>
        <h1>Login Page</h1>
        <form method="post" action="LogIn">
            Username : <input type="text" name="username"/><br/>
            <p>${msg.username}</p>
            Password : <input type="text" name="password"/><br/>
            <p>${msg.userpass}</p>
            <p>${msg.error}</p>
            <input type="submit" value="Login" name="submit"/>
        </form>
    </body>
</html>

--------------------------------
accessDenied.jsp

<%-- 
    Document   : accessDenied
    Created on : Aug 28, 2016, 11:51:43 AM
    Author     : Pukar
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Login Application</title>
        <style type="text/css">
            *{
                font-family: arial;
                font-size: 15px;
            }
        </style>
    </head>
    <body>
        <h1>Page Is Not Found</h1>
    </body>
</html>

---------------------------------------
Demo:


Share on Google Plus

About Ram Pukar

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment

0 comments:

Post a Comment