• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Front controller that doesn't stink

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

I'm tryng to write a Front Controller which can process my urls like this: http://url/controller/method
The idea is ot intercept all the URLs in the web.xml and to route them to the FrontController. Then, the FrontController would call the right method in the right controller (servlet) and pass them the ServletContext and the response et request object.

I've wrote this implementation of my idea:






The issue here is, whenever I call the forward method in my Foo controller, I've got a so big stack trace that I cannot have the original exception...
It looks like this:


Any help would be nice, or if you have a better method to implement my idea I'd be glad to hear it but I don't want to use any framework, i's for purpose learning only. Of course, in a real application I'd use a framework.

Thanks.
 
Bartender
Posts: 543
4
Netbeans IDE Redhat Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is your exception exactly?
 
Antoine Koskoz
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't access to the beginning of the stacktrace, it floods my console :/
 
Sheriff
Posts: 24635
56
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But you're running this front controller in some kind of container, right? (Tomcat, JBoss, Websphere...) So configure that to write logs to a file. In fact it may already be configured that way and you just have to find the log files.
 
Antoine Koskoz
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it has something to do with my web.xml because I solved the issue.

Here is my latest implementation, please tell me what do you think about it.





 
Marshal
Posts: 67279
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Think about this:
 
Antoine Koskoz
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I could return a http 500.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your servlet FrontController is mapped to which urlpatterns receive?
 
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why have you made all methods in controller static? Have you considered about thread safety?
 
rubbery bacon. crispy tiny ad:
professionally read, modify and write PDF files from Java
https://products.aspose.com/pdf/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!