wood burning stoves*
The moose likes JSP and the fly likes <%@page errorPage="%> not Working." title="" /> Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "<%@page errorPage="<file-name>"%> not Working." Watch "<%@page errorPage="<file-name>"%> not Working." New topic
Author

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

prathamesh bandivadekar
Ranch Hand

Joined: May 22, 2008
Posts: 43
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.

Prathamesh M.B.<br />Java....only.....
Shailesh Narkhede
Ranch Hand

Joined: Jul 10, 2008
Posts: 368
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...?


Thanks,
Shailesh
prathamesh bandivadekar
Ranch Hand

Joined: May 22, 2008
Posts: 43
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

Joined: Jul 10, 2008
Posts: 368
Are your Login.jsp & Error.jsp in same folder in web application?
prathamesh bandivadekar
Ranch Hand

Joined: May 22, 2008
Posts: 43
yes. they are in the same folder. outside WEB-INF.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: <%@page errorPage="<file-name>"%> not Working.