aspose file tools*
The moose likes Performance and the fly likes Filter, Edit and Serve - Looking for the best approach Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Performance
Bookmark "Filter, Edit and Serve - Looking for the best approach" Watch "Filter, Edit and Serve - Looking for the best approach" New topic
Author

Filter, Edit and Serve - Looking for the best approach

Rommel Sharma
Greenhorn

Joined: Oct 31, 2003
Posts: 18
Hi All,

I am brainstorming on the best approach for a scenario as follows:

1. Lets say I own:
www.example.com
www.example.co.uk
www.example.de
www.example.fr

2. I have say 100 pages on my website:
www.example.com
and it also has several subdomains setup like
mysite1.example.com
mysite2.example.com

All the content is served in English. All 100 pages have several links to *.example.com (say in header, footer, dynamic content on the pages)

3. Now my requirement is that the same English content be also accessible when a user accesses non .com top level domains like:
www.example.co.uk
www.example.de
www.example.fr

However there should be one change in the pages served: any links to *.example.com should change to the top level domain that is requested for (like example.fr for any request made to *.example.fr).

I have considered the approach of putting in a servlet filter (or Perl filter at the web layer) however the performance difference between the pre and post filter is very high.
Addition of filters is degrading performance. I have tried excluding any non text calls (like for images, videos) from passing through the filter.

I am considering if caching could be brought in here (I want to keep the 100 pages as is in the source code, and only change the links I want to on the fly).

What is your suggestion for a scenario like this?

Many thanks!
Rommel.
Jayesh A Lalwani
Bartender

Joined: Jan 17, 2008
Posts: 2377
    
  28

Why is pre and post filter degrading performance. The filter will basically do nothing.

Can't you do this by just registering all these domains to the same ip? Why do you even need a filter?
Rommel Sharma
Greenhorn

Joined: Oct 31, 2003
Posts: 18
The different top level domains will have different content - in terms of the links shown on the page as they would depend upon which top level domain was requested for. They are pointing to the same ip.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30537
    
150

Rommel Sharma wrote:What is your suggestion for a scenario like this?

The first step is to profile the code and see where the time is actually going. It could be a database call or a faulty regular expression or basically anything. Once you know that, is the time to make the decision on tuning it or caching it.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Rommel Sharma
Greenhorn

Joined: Oct 31, 2003
Posts: 18
Jayesh A Lalwani wrote:Why is pre and post filter degrading performance. The filter will basically do nothing.

Can't you do this by just registering all these domains to the same ip? Why do you even need a filter?


Jayesh, added more details on why filter is needed just below your response.

----

Jeanne Boyarsky wrote:
Once you know that, is the time to make the decision on tuning it or caching it.


Thank you.

For caching: Which caching mechanism, cache available is recommended? It should be able to know that for a particular top level domain the changes have been made to the page so that should be served from cache.

e.g.
User comes to:

winter-clothing.example.de/apparel/collection.html

collection.html has a link:
Also see our [link to: summer-clothing.example.com/apparel/collection.html] summer collection [/link closes]

A java filter detects this page is for example.de, makes a change to the link (note the change fom .com to .de) and sends back:

Also see our [link to: summer-clothing.example.de/apparel/collection.html] summer collection [/link closes]

Next request - from any user to

winter-clothing.example.de/apparel/collection.html

should not go to the java filter but be served from the cache thereby saving processing time and effort.

Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7801
    
  21

Rommel Sharma wrote:A java filter detects this page is for example.de, makes a change to the link (note the change fom .com to .de) and sends back:...

A Java filter? Why? This strikes me as a far more fundamental structural addressing problem; and a Java filter is only ever likely to solve your problem for Java. If it were me, I think I'd be looking to solve it at the DNS level.

Winston

Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
Rommel Sharma
Greenhorn

Joined: Oct 31, 2003
Posts: 18
Winston Gutkowski wrote:
A Java filter? Why?


I will rephrase: The filter (Servlet filter) is to look at the content of the page.

The content under winter-clothing.example.de and winter-clothing.example.com is the same and has in the original file (in this case an html/jsp file that is requested) has several links to *.example.com.

The filter is looking for links pointing to "*.example.com" in the page, checks if the request was for .de and changes just such links within the page to "*.example.de".

How could the content of the page be changed at the DNS level?

William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12787
    
    5
The open-source Cocoon project attempts to provide a general framework for separate manipulation of content and presentation.

It has been years since I looked at Cocoon so I don't know anything about the present version, but you might want to take a look at it.

Bill
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7801
    
  21

Rommel Sharma wrote:How could the content of the page be changed at the DNS level?

It couldn't, but domain and subdomain addressing certainly could; and since you keep referring to "links" that look like DNS names...

However, there may well be other ways of tackling this, and I'm speaking as an old sysadmin rather than a servlet programmer. I still worry a bit about a purely Java-based solution though, because it doesn't seem to attack the basic problem (ie, name-"NAT"ting).

Winston
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Filter, Edit and Serve - Looking for the best approach