This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes difference between action= Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "difference between action="/actionpath" and action="action" in struts" Watch "difference between action="/actionpath" and action="action" in struts" New topic
Author

difference between action="/actionpath" and action="action" in struts

kranthi devarapalem
Greenhorn

Joined: Sep 10, 2012
Posts: 14
Hi all

i have a general doubt in struts and here it goes

is there any difference between below two in behavior
1.<struts:form action ="/loginaction">
2.<struts:form action="loginaction">

is there any difference between below two in behavior
1.<forward name = "confirm" path="/confirm.do"/>
2.<forward name = "confirm" path="/confirm"/>


does "/" makes any difference in the flow?


Thanks
kranthi.
Saif Asif
Ranch Hand

Joined: Aug 11, 2011
Posts: 440

Hello kranthi devarapalem,

Yes the "/" will make a big difference. whenever you reference anything with "/" , the requested resource will be searched for at the root of the server. However, if you do not specify "/" , then the resources will be searched in the current directory from which it is being referenced from.

The same following logic applies to both the struts action tag and the forward tag of the jsp as well.
This JSP will be searched for at the root of the server ( NOT the root of the project ). The URL will be localhost:8080/abc.jsp


However, just omit the "/" and the whole URL changes to localhost:8080/<project_context_name>/<some_dir>/abc.jsp

So yes , the "/" will make quite a huge of a difference.


Muhammad Saif Asif Mirza
OCJA(5/6) OCJP(6) OCJWCD(6)
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: difference between action="/actionpath" and action="action" in struts
 
Similar Threads
.tld files
struts java.lang.IllegalAccessException
dispatcher Vs action dispatcher
httpServlet and action servlet
Struts 2 welcome-file-list