aspose file tools*
The moose likes Struts and the fly likes Customizing 404 error messages in Struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Customizing 404 error messages in Struts" Watch "Customizing 404 error messages in Struts" New topic
Author

Customizing 404 error messages in Struts

Shashi Iyyanar
Greenhorn

Joined: Feb 26, 2004
Posts: 4
Hi all,
I am using form-based authentication in my Struts-based application.I am encountering some problem in my application.Normally,a user logins to the application.But,on login,if he tries to go back to the login page again using the browser "Back" button and if he logins again,he is presented with a "HTTP Status 404" error page from the server stating that a invalid direct reference has been made to the login page or the requested resource(/application name/j_security_check) is not available.This is due to the fact that the user has already logged in to the application but is trying to login again.I want to customize the 404 server error message page so that the user is informed about the error in a more friendly way.
I want to know how to solve this problem.If there is any example code to overcome this problem,it would be very much easier for me to solve my problem.Waiting for a positive response.Thank in advance.
poornima balagopal
Ranch Hand

Joined: Dec 02, 2003
Posts: 83
Hi,
I dont have much idea. But in the Orelly's struts book(Prgramming Jakarta Struts) they have given some code part for configuring Error handling in web.xml
The following code part they have given as an example to prevent users from seeing 404 or 500 (internal server)error
<web-app>
other elements
<error-page>
<error-code>404</error-code>
<location>/common/404.jsp</location>
</error-page>
</web-app>
When an error status code is set in the response , the container consults the list of error page declarations for the web application. If the match found, the container returns the recource indicated by the location element.
the value of the location element muct begin with a "/" character and it must refer to a recource within the web application
This is the explanation they gave in the book
For more detailed explanation you can go through that book
try
all the best
Poornima
 
 
subject: Customizing 404 error messages in Struts