From: markspace on
Lew wrote:
> Arne Vajhøj wrote:
>>> Why would:
>>> Apache HTTPD with mod_rewrite -> Apache Tomcat
>>> not work?
> ....
>
> markspace wrote:
>> What if Apache isn't your web server?
>
> In general a good question. In the OP's particular case it's pretty
> clear they're in control of the environment and can choose it to be.
>


Seems like a good way to get bit if you ever export the web app to a
different environment. Sure, Apache is very popular and you can just
spec the app that way to customers, but it's also just one more thing to
deal with manually (the mod_rewrite stuff) that doesn't need to be, I
suppose.

From: Arne Vajhøj on
On 28-07-2010 20:43, markspace wrote:
> Arne Vajh�j wrote:
>> Why would:
>> Apache HTTPD with mod_rewrite -> Apache Tomcat
>> not work?
>
> Did you try it? Did it work? I'm honestly interested to know, it never
> occurred to me that it might work.

I have not tried it, but I would expect it to work.

If used with PHP it is:

---(original request)-->mod_rewrite--(modified
request)-->mod_php---->PHP scipt

With Tomcat it should be:

---(original request)-->mod_rewrite--(modified request)-->mod_jk--(AJP
protocol)-->Tomcat

Given the functionality of mod_rewrite it must be executed before
the real mod's and be rather independent of what those mod's do.

At least that is my expectation.

>> I don't think that provides nearly as much functionality as mod_rewrite
>> when it comes to smart rewrites.
>
> What if Apache isn't your web server?

The using an Apache module like mod_rewrite is obviously not an option.

Arne

From: Lew on
markspace wrote:
>>> What if Apache isn't your web server?

Lew wrote:
>> In general a good question. In the OP's particular case it's pretty
>> clear they're in control of the environment and can choose it to be.

markspace wrote:
> Seems like a good way to get bit if you ever export the web app to a
> different environment. Sure, Apache is very popular and you can just
> spec the app that way to customers, but it's also just one more thing to
> deal with manually (the mod_rewrite stuff) that doesn't need to be, I
> suppose.

It is not uncommon to spec requirements for an app to run. And some kinds of
portability are overrated. I'm not necessarily speaking in favor of
mod_rewrite, but I do think httpd is an awesome product and one should not be
ashamed or fearful of basing an application on it.

And there are hundreds of products on the market that already spec it as part
of their product. Ever hear of LAMP?

--
Lew
From: Tom Anderson on
On Wed, 28 Jul 2010, markspace wrote:

> Also, use the fact that WEB-INF is private to hide JSPs and servlets
> that you don't want the user calling directly.
>
> Web Pages \
> index.jsp
> other-public.jsp
> WEB-INF \
> private.jsp
> myplugin \
> plugin.jsp
> etc.
> css \
> public.css
> images \
> public.jpg
>
> Etc.

Nice trick! I didn't know that one. You could hide config files and so on
like this too.

tom

--
The art of medicine consists in amusing the patient while nature cures
the disease. -- Voltaire
From: Tom Anderson on
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