Dear Friends,
As I mentioned before, I have a simple modular structure of my
website. Let me describe it as:
- Main page, which contains a menu bar with few page-links, ie.
- News
- Users
- Requests
- Options
- Anything more
Each page-link has sub-links, as following: “New”, “Edit”,
“Browse” (typical).
(In PHP, I’d href them like: “/news/add” or “/users/browse”)
What I’ve been doing lately in PHP, I’ve used a mod_rewrite powerful
tool, which rewrites me request string like so:
if(!index.php)
rewrite /any/friendly/url to /index.php?p=any/friendly/url
Inside the index.php I’ve parsed the “p” argument into ARGV/ARGC-style
based Array – ARGV[0] -> any, ARGV[1] -> friendly, ARGV[2] -> url,
etc. Cool.
When it was done, I’ve build big switch statement, which direct the
HTML-output regarding to ARGV[0-n] parameters, as following:
$PageObject = HTML_TEMPLATE(“index.tmpl”);
switch(ARGV[0]) {
case “news”:
switch(ARGV[1]) {
case “add”:
// Do something
$PageContentElement = HTML_TEMPLATE(“subpage.tmpl);
$PageContentElement->Add(“add some data here”);
$PageObject->Add(“PageSection_Menu”,
$PageContentElement->GetObjectHTML());
break;
case “edit”:
// Do something else
break;
}
break;
case “users”:
// analogical as in “news” case
break;
// other cases
}
$PageObject->DisplayHtml();
/*
print out <html>*</html> main template including the replaced
variable elements
*/
The PageObject is a simple template engine, which I’ve wrote to parse
pure-HTML files, which contain {Variable} elements, which might be
changed by RegExp with defined value (depending on switch statement
and ARGV variables).
At the end, I just printout the PageObject data, with changed content
– done.
That was my idea of PHP webpage engine and as I see that logic is
quite impossible in JSP. Here the problems occur.
I wish you understand how my php-logic seems to work, now tell me
please, how do I rewrite it into JSP style?
As I understood, I may create a index.jsp file, which contains the
default page template (including menus, footers, all that crap), with
links to my modules – ie. /news or /users.
I’ve been told, that I may connect the /news url with some java
servlets (via web.xml). Sounds cool, but is it possible to connect the
main index.jsp file with servlet output? On the other hand, is it
possible to get from index.jsp a page template layout and copy/move it
to my servlet element?
I don’t have any problems with dividing my pages into plenty jsp
pages, but what I want to achieve is NOT make changes in each jsp page
in the static sectors (like menubars, styles, etc.) When there are few
files, n/p, but when I build like 20 sections, that would be annoying.
Oghr, don’t be mad on me, I’m trying to understand everything. Now
when I’ve clarify my application structure, I presume it might be
easier for you to understand what I really want
Thank you,
Przemek M. Zawada