Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
kranthi devarapalem
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 440
Eclipse IDE Hibernate Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic