• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Frontman 2.0 need to throw 404 error instead of CommandNotFoundException

 
John Schretz
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
John Schretz
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Been there, done that!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic