You can add a parameter to the global-forwards, and then
check for it. For example:
<global-forwards>
<forward name="selectRentalCar"
path="/CarMenu.jsp?where=select"/>
<forward name="addRentalCar"
path="/CarMenu.jsp?where=add"/>
</global-forwards>
and then use, in the action class:
if(request.getParameter("where").equals("select")) {
// something; }
else if(request.getParaneter("where".equals("add")) {
etc.
}
-- Larry Maturo
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Monday, August 20, 2001 4:12 PM
To: [EMAIL PROTECTED]
Subject: Reuse of JSPs
I have a few JSPs for the app I am working on that are virtually identical.
Boilerplate on them changes based on how you got to that screen. I was
thinking that I could have a single JSP in these cases, and determine which
boilerplate is to be displayed by some kind of custom tag that evaluates
the navigation. My first thought is to use global forwards in the struts
config, so for instance we have:
<global-forwards>
<forward name="selectRentalCar" path="/CarMenu.jsp"/>
<forward name="addRentalCar" path="/CarMenu.jsp"/>
</global-forwards>
So say the CarMenu jsp has some text on it that changes based on whether
the user is choosing their first rental car for a trip or adding a
subsequent rental car. Stupid example, but bear with me ;-).
Is there already a way within Struts for me to figure out from the JSP
whether or not I came from a "selectRentalCar" or "addRentalCar"
forwarding? I've eyeballed the Struts bean tag, but can't find an example
of its use to be sure if there is a Struts object on the request that I can
expose to determine this value....
Alternatives?
Jim