aspose file tools
The moose likes Struts and the fly likes Purpose of having '.do' Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Reply Bookmark "Purpose of having Watch "Purpose of having New topic
Author

Purpose of having '.do'

avaj eikunj
Greenhorn

Joined: Mar 04, 2011
Posts: 4
What is the purpose of having '.do' in the actions or URL? why .do? Why not just leave it as it is? such as '/browse' instead of /browse.do ?
debraj mallick
Ranch Hand

Joined: Mar 08, 2011
Posts: 188

if you are not happy with .do change it, like


also you can try URL rewrite
http://www.tuckey.org/urlrewrite/
http://urlrewritefilter.googlecode.com/svn/trunk/src/doc/manual/3.2/index.html
avaj eikunj
Greenhorn

Joined: Mar 04, 2011
Posts: 4
No no.....what I meant was why one should even have a .do or a .avaj? Wht cant it be

<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>/browseCatalog instead of /browseCatalog.do</url-pattern>
</servlet-mapping>

is it some kinda namespace we are trying to resolve to?
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8260

The problem with a URL pattern of /browseCatalog is that you would only be able to map a single web context to a Struts action. You want to have some sort of wildcard so you can map multiple contexts and use multiple Struts actions.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Kaur Manpreet
Ranch Hand

Joined: Feb 14, 2012
Posts: 30

Hi Joe,

Understand that if we specify an exact name in the <url-pattern> tag, we are mapping only one web context to a struts action and when we add *.do in the <url-pattern>, all URL's that have .do as extension would rightfully be mapped to struts action.

What I am unable to understand here is how is .do suffix appended to each and every URL. Is there a rule for that or is there some mapping which I overlook?

Thanks
Manpreet
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56174
    
  13

You can also use prefix mapping such as: /action/*

In fact, the move to "friendly" and RESTful URLs make the .do convention (which I have always detested) a bit antiquated.

[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Kaur Manpreet
Ranch Hand

Joined: Feb 14, 2012
Posts: 30

Hi Bear,
My question is regarding the appending of extension .do (or any other specified in <url-pattern>) to the existing URL.

How is this happening?
Is it behind the scenes (as a rule or out of box feature of Struts).

Thanks
Sandip Ram
Greenhorn

Joined: Jun 13, 2012
Posts: 4
Hi,
Nice Question dear.
Before i mention the answer of your question first i want to tell the definition of of frame work.
"A framework defines a well defined procedure to carryout a task"
So the task means some work. And carry out means to do the work.
So struts guys are followed this convention and for doing the work they use do.
I think you clear a little bit.

This is for struts 1.x and for struts 2.x also now you guess what the do(just use action incase of .do ).

Thank you.
Daniel Val
Ranch Hand

Joined: Jan 09, 2012
Posts: 39
Kaur Manpreet wrote:Hi Bear,
My question is regarding the appending of extension .do (or any other specified in <url-pattern>) to the existing URL.

How is this happening?
Is it behind the scenes (as a rule or out of box feature of Struts).

Thanks


Hi,

Struts is an MVC. Like any MVC, it has a front controller, which is the ActionServlet. All the requests within the application must go through the front controller who will then dispatch them to the right action.

The Action Servlet is defined with the url pattern *.do, that's why you see the calls like response.do etc.

How it is done: when you put <html:form /> tag, it will render a html form tag that will have action geared to the *.do url.

If you don't like *.do you can change it, however all the html form tags in your application will be rendered to direct all your posts to that ActionServlet front controller.

D.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Purpose of having '.do'
 
Similar Threads
Dynamic JNDI
How to make AXIS start a class each time it starts?
life
Why do we use Constructors in Java ?
Main() Class