if I understand correctly what you'd like to achieve, one way to do it would
be to use the Templates or Tiles tag library:
- you setup one template: /CarMenu.jsp with the reusable HTML code :
<%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>
<html>
<body>
<table>...</table>
<!-- this would insert some text using the Templates taglib -->
<template:get name="someText" />
</body>
</html>
- you use one jsp page for selectRentalCar aka /SelectRentalCar.jsp which
simply uses the CarMenu template and provide it with the appropriate message
<%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>
<template:insert template="/CarMenu.jsp">
<template:put name="someText">selectRentalCar text</template:put>
</template:insert>
- and you use another jsp page for addRentalCar (/AddRentalCar.jsp) which
also uses the CarMenu template
<%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>
<template:insert template="/CarMenu.jsp">
<template:put name="someText">addRentalCar text</template:put>
</template:insert>
it's good practice to store your templates under the WEB-INF/ path to
prevent direct access from browser requests (internal access from Servlets
or JSPs will still work, though).
nicolas b.
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Monday, August 20, 2001 11: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
>