Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Servlets and the fly likes Front controller that doesn't stink Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Front controller that doesn Watch "Front controller that doesn New topic
Author

Front controller that doesn't stink

Antoine Koskoz
Greenhorn

Joined: Feb 28, 2010
Posts: 9
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.
Dieter Quickfend
Bartender

Joined: Aug 06, 2010
Posts: 505
    
    4

What is your exception exactly?


Oracle Certified Professional: Java SE 6 Programmer && Oracle Certified Expert: (JEE 6 Web Component Developer && JEE 6 EJB Developer)
Antoine Koskoz
Greenhorn

Joined: Feb 28, 2010
Posts: 9
I can't access to the beginning of the stacktrace, it floods my console :/
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

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

Joined: Feb 28, 2010
Posts: 9
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.





Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

Think about this:


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Antoine Koskoz
Greenhorn

Joined: Feb 28, 2010
Posts: 9
Yes, I could return a http 500.
Saulo Siqueira
Greenhorn

Joined: Mar 27, 2012
Posts: 2
Your servlet FrontController is mapped to which urlpatterns receive?
Piyush Mangal
Ranch Hand

Joined: Jan 22, 2007
Posts: 196
Why have you made all methods in controller static? Have you considered about thread safety?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Front controller that doesn't stink
 
Similar Threads
passing session values between two web application
servlet deployment issue on websphere server.
display the log/output in JSP or HTML page
My first post (thank): report with subreport open
Error message: Cannot forward after response has been commited