I am just getting started on web app development. I have an index.jsp that has just ONE line.
< jsp:forward page="landing.do?"/>
What does
the above line do?
page="landing.do?" actually refer to?
what does the question mark "?" next to "landing.do?" signify?
As Bozho rightly pointed out, a servlet called "action" is mapped to handle "*.do" in my web.xml (as shown below).
<servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping>
Now
How do I find out what the servlet "action" corresponding to "landing.do" actually does?
Thanks.
The
<jsp:forward>forwards a client request to the url declared on thepageattribute.I also need to mention that in your example, you should have a
/as first character inside yourpagedeclaration, if you want to specify a relative URL, i.e.:This, in effect, is translated as a redirection to (if localhost)
http://localhost:8080/MyAPP/landing.do? (yours would have been translated to http://localhost:8080/MyAPPLanding.do?)
The
?allows you to appendapplication/x-www-form-urlencodedparameters into your declaration.More info here.
To know what
landing.dodoes, do the following:struts-config.xml(found inWEB-INFfolder in your project) file and find any action (<action>) that apath="/landing") attribute.type(inside that action). The type is a the class name of the action class that Struts calls to execute the action. The class name is fully qualified name.Action,DispatchAction,LookupDispatchAction), you will have to find its mappings and see what method Struts invokes.landing.dois of typeAction. Therefore, read what theexecute()method does. All actions actually, isexecute()by Struts. The other actions are justTemplate Methodpatterns that knows what method to call by some mapping.