• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Why sometimes servlets have got .do extension (why this)

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I have read HF three times, but I haven`t find an answer to this question: Why sometimes servlets have got extension .do - Even in HF, at the beginning of the book, a few of the servlets have got this extension. Now I open this site: https://www.suntrainingcatalogue.com/eduserv/chooseLocale.do and here is also this extension. So why .do ? :
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's a rather silly tradition from Struts 1.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why not? Does it matter?

Most of the time .do indicates that the Struts framework was used. It makes it easy to map all *.do requests to the Struts controller servlet. You wouldn't want to map *.jsp to the Struts servlet, because then you couldn't have any Struts-free .jsp pages; so something else is used.

Another reason might be backwards compatibility. Maybe a site was formerly implemented in Cold Fusion, resulting in lots of *.cf URLs that are all over the place. Instead of breaking all those URLs, you simply map *.cf to the JspServlet (in addition to *.jsp), and -presto!- all your *.cf pages can now contain JSP code instead of Cold Fusion code.
 
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
let's say you have a web app, and one part of it is public to the whole world, the other part is only for registered users. ..

you could declare a security constraint that acts upon all urls that are mapped to /rootPath/secure

instad though, you could achieve the same goal by using a predefined extension for the secured part of you web app, something like <url-pattern>*.secure</url-pattern>

now, as for .do, do is a common extension for the Struts web framework.

The struts framework processes all it's request thru something called a front controller, to centralize navigation.

how it achieves this is by a simple filter that is invoked for every url that ends in .do




so in general, it is a common way to identifiy or dedicate or certain area or requirement in your web app.

as an example, imagine you offer a download service that offers short text documents for download.
You want to offer the text docs for direct download, but also in zip format,

so what you would do is create a filter that maps to urls that end in .zip which then wraps up the response into a ZipOutputStream.
this also encapsulates other code, since all you do is create a filter without touching further business classes
 
Tom Kowalski
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply, I am grateful.
 
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Would the servlets mapped to *.A and those mapped to *.B share the same ServletConfig or ServletContext ?

Regards
 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
context yes - since the servlet context is one per web app ...

servlet config depends

if you have one servlet with two mappings, then it has the same ServletConfig

If you declare the same servlet in two different <servlet> tags, they get their own servlet config, as well as they each have their own instance ...
 
He was expelled for perverse baking experiments. This tiny ad is a model student:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic