• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
prathamesh bandivadekar
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • 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.
 
Shailesh Narkhede
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
  • 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: 43
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Are your Login.jsp & Error.jsp in same folder in web application?
 
prathamesh bandivadekar
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes. they are in the same folder. outside WEB-INF.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic