Re: JSP Web-Development [newbie]
On Wed, 28 Jul 2010, pmz wrote:
I'd like to have ONE default JSP page (which obviously contains a
webpage main layout - styles, scripts, tables, images, etc.). In few
places I have some dynamical stuff (such as parameter-regarded menu
display or also parameter-regarded body display).
Shall I use you <c:choose/> method for further inclusion of required
jsp-sub-pages?
No. You're doing this all wrong. Or rather, you're doing it all PHP, which
in JSP means wrong.
Use separate pages for the different pages, and a tag file to define the
common structure:
http://www.oracle.com/technology/sample_code/tutorials/jsp20/tagfiles.html
A tag file is the analog of a framework method in code; it can write a
load of HTML, but can also invoke fragments passed by the original
invoker.
For example, given a tag file like this (call it main.tag):
<%@ attribute name="content" required="true" fragment="true" %>
<html>
<body>
<h1>PMZ's SUPER SITE</h1>
<jsp:invoke fragment="content"/>
</body>
</html>
You could write a JSP like this:
<%@ taglib prefix="mytags" tagdir="/WEB-INF/tags" %>
<mytags:main>
<jsp:attribute name="content">
<p>Some content.</p>
</jsp:attribute>
</mytags:main>
This would invoke the main.tag to build the page structure, which would
then call down to the fragment defined in the JSP. You can have multiple
fragments, and also use normal content of the tag via <jsp:doBody/>.
tom
--
The art of medicine consists in amusing the patient while nature cures
the disease. -- Voltaire