Win a copy of React Cookbook: Recipes for Mastering the React Framework this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

<%@page errorPage="<file-name>"%> not Working.

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am writing following code:

<%@page errorPage="Error.jsp"%>

<%

String user = (String)request.getParameter("uname");

String password = (String) request.getParameter("password");

try{
if(user.equals("Prathamesh") && password.equals("India")){

out.println("Welcome");

out.flush();

RequestDispatcher rd = request.getRequestDispatcher("/Welcome.jsp");

rd.include(request, response);


}else{
throw new Exception();
}

}catch(Exception e){
throw new Exception("Servlet Error");
}

%>

Whenever i enter wrong password it should go to Error.jsp which is as follows:

<%@page isErrorPage="true" %>

Error Welcome !

<%= exception.getMessage() %>


But it gives Http 500

The website cannot display the page
HTTP 500
Most likely causes:
The website is under maintenance.
The website has a programming error.

Help will be much appriciated.

Regards,
Prathamesh.
 
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi prathamesh,

First of all use code tags for code segments it will be easy to read.

When are you getting 500 while visiting your login JSP or after try to login...?
 
prathamesh bandivadekar
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When i m trying to login, i have given a dummy logic hardcoding the uname and password.

if the uname and password do not match , the processing logic throws Exception.

Just to demonstrate the errorPAge attribute of the Page Directive i m using this exception.

If i use try-catch block in the processing, it works. But do no transfer the command to ErrorPage(which is intended).

If i remove that try-catch...It gives Http 500 error.

Login.jsp >>> LoginProcess.jsp(Process Logic)>>>> If Successful >>>> Welcome.jsp
If Failed >>>> Error.jsp
 
Shailesh Narkhede
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are your Login.jsp & Error.jsp in same folder in web application?
 
prathamesh bandivadekar
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes. they are in the same folder. outside WEB-INF.
 
Are you here to take over the surface world? Because this tiny ad will stop you!
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic