aspose file tools*
The moose likes Servlets and the fly likes Controller Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Controller Question" Watch "Controller Question" New topic
Author

Controller Question

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15286
    
    6

Right now, my url-pattern for my Controller is *.do. While this works, I just don't like the look of page.do in the URL on the browser.
I would rather not have an extension at all. I initially tried just using /* for my URL-pattern and this worked until I forwarded to a JSP then I just got caught in the awful loop because it kept hitting the Controller over and over for every request.
The other option I tried, which worked, was to map all my actions to something like /action/*. That way, my JSP's were never in that url-pattern, so I lost the loop.
However, is there any way to say something like "all but .jsp" are mapped through the controller? Or is it best to just make the url-pattern something where the JSP's aren't located. As in /action/*?
Thanks.


GenRocket - A Test Data Generation Platform
Tim Baker
Ranch Hand

Joined: Oct 04, 2003
Posts: 541
IIRC it is not possible to do negatives in URL patterns, it's not like a regular expression.
I would recommend a mapping like index.html just so that people can't guess what technology you are using and it looks 'normal' in a browser


Kim Jong II (North Korea's Dear Leader) said:Nuclear weapons don't kill people, people kill people.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15286
    
    6

Originally posted by Tim Baker:
IIRC it is not possible to do negatives in URL patterns, it's not like a regular expression.
I would recommend a mapping like index.html just so that people can't guess what technology you are using and it looks 'normal' in a browser

Good suggestion. Why hide the technology though?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60055
    
  65

I would recommend a mapping like index.html just so that people can't guess what technology you are using and it looks 'normal' in a browser

Be afraid. Be very afraid.
If you do this, "helpful" servers on the web (most notably AOL) will cache your results thinking that the content is static. (Thus ending up with bugs like one customer's data beng presented to another -- not pretty and I have the scars to show for it).
I use /action in my framework. There's no sense in "hiding" the technology to me.
bear
[ December 29, 2003: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ken Robinson
Ranch Hand

Joined: Dec 23, 2003
Posts: 101
I also like the 'technology' hiding. I not only like to 'hide' the implementation from the user, but the extension is also the perfect place to find out what 'flavor' the user wants (html, wml, pdf, etc..).
I believe (I may be wrong) that a URL without an extension is usually translated, or assumed to be, as a directory. In any case, I would assume that you would only want the controller logic to execute once per request. I see why you are not a fan of *.do, but explicitly forcing all .do request through the controller is exactly why STRUTS selected to go that way.
One way around it that I can think of is to create a super class servlet that contains all controller code not having to do with mapping (security and such). Then just map each servlet (extending the super class of course) to each URL as normal in web.xml. I suggest putting any objects/vars in the ServletContext or a seperate Static class and only put methods in the superclass.
Ken Robinson
Ranch Hand

Joined: Dec 23, 2003
Posts: 101
Originally posted by Bear Bibeault:

Be afraid. Be very afraid.
If you do this, "helpful" servers on the web (most notably AOL) will cache your results thinking that the content is static. (Thus ending up with bugs like one customer's data beng presented to another -- not pretty and I have the scars to show for it).


Is it not possible to set the page lifetime or cache life to zero or to expire in the past to avoid this?
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15286
    
    6

Originally posted by Kenneth Robinson:


Is it not possible to set the page lifetime or cache life to zero or to expire in the past to avoid this?

I think for AOL no, because the integrated AOL browser ignores META tags to disable caching (I think).
Since AOL is primarily Dial up, they cache like crazy for speed purposes.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Controller Question
 
Similar Threads
How to access EntityBean data from JSP page???
design help
Security Problem with my app
Preferred Pattern (Industry Standard?)
test.jsf works test.jsp doesn't