aspose file tools*
The moose likes Other Application Frameworks and the fly likes Frontman 2.0 need to throw 404 error instead of CommandNotFoundException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Frontman 2.0 need to throw 404 error instead of CommandNotFoundException" Watch "Frontman 2.0 need to throw 404 error instead of CommandNotFoundException" New topic
Author

Frontman 2.0 need to throw 404 error instead of CommandNotFoundException

John Schretz
Ranch Hand

Joined: Sep 10, 2008
Posts: 188
If a url is requested that is not "valid" the command class is not found, and commandBroker throws a CommandNotFoundException.

in reality i would want this to be a 404 exception so my error page picks it up and i can differentiate between the fact that the page was just not found and an actual internal error in my java code.

Example: i have a good url here: http://127.0.0.1:8080/ecommerce/store/department/15/category/1

for some reason the user throws an m at the end or messes with the url :http://127.0.0.1:8080/ecommerce/store/department/15/category/1/m

Currently this throws a java exception and error_java.jsp is displayed, i really need error_404.jsp to be displayed because its just a bad url and page not found.
I would only want error_java.jsp to be displayed in the case that and actual java error happened in my code.

Is this possible to do with Frontman? Even if i had to alter source code?

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61420
    
  67

This change will not be made. As it is, you can capture the exception and do anything you want with it, including returning a 404. It is not Front Man's job to decide what the response code should be -- that level of control remains in the hands of the web devo.

Of course, if you disagree, the source code is yours to change as you see fit.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
John Schretz
Ranch Hand

Joined: Sep 10, 2008
Posts: 188
Where would I catch that exception? as it is now it does not make it to the execute method and not to any part of the code i have written.
Id rather not change the source code, i would like to do it the correct way, im just not sure how.

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61420
    
  67

Declare an error handler in the deployment descriptor for that exception type.

Remember, one of the whole points of Front Man is to not redefine how you do everything. All the normal servlet and JSP techniques can, and should, be used.
John Schretz
Ranch Hand

Joined: Sep 10, 2008
Posts: 188
Bear Bibeault wrote:Declare an error handler in the deployment descriptor for that exception type.

Remember, one of the whole points of Front Man is to not redefine how you do everything. All the normal servlet and JSP techniques can, and should, be used.


That did it, been a long day. Brain is running 100mph ahead of me

Thanks,
John
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61420
    
  67

Been there, done that!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Frontman 2.0 need to throw 404 error instead of CommandNotFoundException