473,324 Members | 2,417 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

CMS / servlet-like program

Hi,

I'm developing a very small, basic bespoke MySQL-based website, and
there are effectively 3 ways (as far as I'm aware) to do what I want
to do, but I'd like some opinions on what people think would be best.

Currently, I have the pages included like: www.site.com/index.php?p=about,
www.site.com/index.php?p=contact, and also, for the book include,
www.site.com/index.php?p=book&id=1

The book information is the only information held in the database.
All other pages are just included (an elaborate, long server-side
include I guess!). I could continue this way, but I would much rather
have URLs that make sense, and I can see 2 possible solutions:

1. Use Apache rewrite to make the URLs look 'real' (e.g.
http://www.alistapart.com/articles/urls/)

2. Sort all the current pages to be about.php, contact.php etc., and
write a servlet-type page that actually creates real plain HTML pages
for the information about the books, (e.g. www.site.com/books/book1.html).
My plan is to have user-input to put the book information into the
database, so I assume it would be relatively trivial to actually
create a real page when they have entered the information via an input
page (/input.php, instead of using phpMyAdmin).

I'd be grateful for any comments people might have,

Thanks,
Chris

Jul 17 '07 #1
2 1809
C.
On 17 Jul, 12:53, ChrisW <c.c.w...@gmail.comwrote:
Currently, I have the pages included like:http://www.site.com/index.php?p=abou....php?p=contact, and also, for the book include,www.site.com/index.php?p=book&id=1
Sounds like your trying to model your PHP application architecture on
Java's. Possibly not the best starting point.

I fail to see any advantage in using a front controller architecture
with PHP (but if anyone can convince me otherwise...) and there are
some major drawbacks - particularly code complexity and transparency
of structure.
1. Use Apache rewrite to make the URLs look 'real' (e.g.http://www.alistapart.com/articles/urls/)
....hides the front controller - but wouldn't it be better to make
proper use of templates and include files to map URLs directly to
script entry points.
2. Sort all the current pages to be about.php, contact.php etc., and
write a servlet-type page that actually creates real plain HTML pages
for the information about the books, (e.g.www.site.com/books/book1.html).
Introduces unnecessary complexity and dependencies in the code. By all
means make the output cacheable - you could even get performance
improvements by running a caching reverse proxy on the same box as the
webserver. Alternatively implement the caching in your code:

(untested)
$cache_file=get_cache_file_for_url($_SERVER['PHP_SELF']);
if (cache_file_is_valid($cache_file)) {
$fh=fopen($cache_file, 'r');
fpassthru($fh);
fclose($fh);
} else {
// wrap in output buffering to create the cache file here
include_once($actual_php_page) || die('no php script here');
//
}

What happenned to option 3?

C.

Jul 18 '07 #2
On Jul 18, 2:21 pm, "C." <colin.mckin...@gmail.comwrote:
On 17 Jul, 12:53, ChrisW <c.c.w...@gmail.comwrote:
Currently, I have the pages included like:http://www.site.com/index.php?p=abou....php?p=contact, and also, for the book include,www.site.com/index.php?p=book&id=1

Sounds like your trying to model your PHP application architecture on
Java's. Possibly not the best starting point.

I fail to see any advantage in using a front controller architecture
with PHP (but if anyone can convince me otherwise...) and there are
some major drawbacks - particularly code complexity and transparency
of structure.
I'm not quite sure what you mean by modelling the application
architecture on Java's. Perhaps I wasn't clear enough, I was meaning
that I use the $_GET method, so that the URL variable is showing what
page should be included. It seems a lot of websites make use of this
method, but is it a relatively bad way to do things?

This is the 1st way that I had thought to continue.
1. Use Apache rewrite to make the URLs look 'real' (e.g.http://www.alistapart.com/articles/urls/)

...hides the front controller - but wouldn't it be better to make
proper use of templates and include files to map URLs directly to
script entry points.
If I understood how to do that then I might agree it's better :) I'll
go and have a look...
2. Sort all the current pages to be about.php, contact.php etc., and
write a servlet-type page that actually creates real plain HTML pages
for the information about the books, (e.g.www.site.com/books/book1.html).

Introduces unnecessary complexity and dependencies in the code. By all
means make the output cacheable - you could even get performance
improvements by running a caching reverse proxy on the same box as the
webserver. Alternatively implement the caching in your code:

(untested)
$cache_file=get_cache_file_for_url($_SERVER['PHP_SELF']);
if (cache_file_is_valid($cache_file)) {
$fh=fopen($cache_file, 'r');
fpassthru($fh);
fclose($fh);} else {

// wrap in output buffering to create the cache file here
include_once($actual_php_page) || die('no php script here');
//

}

In what ways could / would writing the data to individual static html
files add dependencies?
What happenned to option 3?
The third way is the way that I'm currently using.

Thanks,
Chris

Jul 19 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Rose Girl | last post by:
Hi Need some help on javascript. I need to know how to call a servlet from a javascript function. web-inf (jboss) path for servlet is: com.purpleace.ripple.admin.contacts.servlet.AdminReport...
1
by: Farce Milverk | last post by:
Hi, Is it possible to have a Servlet on Server A call a Servlet on Server B (both running single instances of an identical webapplication) without using a Proxy setup? For example, if a request...
7
by: bylum | last post by:
Servlet SQLException Communication link failure java howto i can't connect jsp and database(mysql). This is the exception: exception org.apache.jasper.JasperException:...
7
evilmonkey
by: evilmonkey | last post by:
My assignment was to create a shopping cart servlet, it works locally on tomcat but when I deploy it to the schools server (also tomcat) it fails to refresh the front page and just prints the HTML...
0
by: krishna81m | last post by:
Could some one please explain why the session is not being maintained when I am doing a forward in a servlet after setting a cookie. I am even unable to set session attributes or parameters and...
6
by: Sushmita | last post by:
hi all, I have wrriten code for a small web application. From my JSP page i am not able to call the servlet.. its throwing an exception. "javax.servlet.ServletException: Wrapper cannot find...
3
by: krishna81m | last post by:
Hello, I am looking for a solution to update a .jsp page (kind of progress bar) which shows current progress in a huge simulation when users have to wait for longer periods and the way to do it...
2
by: ManidipSengupta | last post by:
Hi, a few (3) questions for the Java experts, and let me know if this is the right forum. It deals with 100% java code (reason for posting here) but manages a Web browser with Javascript. Thanks in...
3
by: vijaykumardahiya | last post by:
Dear Sir, I have two queries. First question is: I have a Html page. On which Have two buttons Submit and Issue. I want when I click on Sumit button request should be go to submit.jsp. and When I...
9
by: mjahabarsadiq | last post by:
Hi I have created a servlet that is to be started at the server startup. And I got it. In that I have created a object of another class and set it as a session attribute. What I am trying is...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.