SourceForge.net Logo
Homepage | SF Summary | Download | Mbuyu
 

PHPBB2servlet - Java J2EE forum intergration

What is this?
What is the exact use for this?
Is there an example available?
What do I need to run the example?
How do I use the servlet in my own application?
What are the future plans?
Why was this implemented?




What is this?

Phpbb2servlet integrates a PHPBB2 forum into a J2EE application or website. This means a bridge is being made between the PHP and Java world.


What is the exact use for this?

There are two possible uses for this (they can be combined of course)

  1. The J2EE application user can be synchronized with the PHPBB2 user
  2. The PHPBB2 forum can be visually integrated into the J2EE site.
For 1) The J2EE application needs to put an object into the user's session that can return the username and password for PHPBB2. In the simplest case, this will be the same object that models the J2EE user and simply implements the required IWebSiteUser interface, returning the same name and password as in the J2EE application. A system administrator should take care of creating accounts on both the J2EE app and PHPBB2 with the same names and passwords. Of course, the object implementing IWebSiteUser can be any object, that may perform any kind of logic for retrieving the required name and passwords.

For 2) The J2EE application needs to provide a top header and a footer (bottom) include. Typically, a lot of J2EE applications already make use of this kind of includes. If one or both of these make use of relative links, then they possibly don't work anymore when they are used for the path onto which this servlet is mapped. Many J2EE applications solve this problem, by setting their own base in the HTML head. However, when setting such a base the PHPBB2 links don't work anymore, since they won't be mapped to the servlet path anymore.

E.g.
When the base of a J2EE app is set to www.example.org and this servlet is mapped to /forum (so it becomes available at www.example.org/forum), then all PHPBB2 links (like showtopic), will wrongly point directly to www.example.org.

Therefore, this servlet supports setting this base and adjusting it for PHPBB2. To aid in this, some example code has been provided that makes use of this feature.


Is there an example available?

The source code comes with a very basic J2EE 1.3 based web application. This web application demonstrates the user authentication and the J2EE 'frame' that surrounds the forum. As an example, the M4N forum (in Dutch) is chosen, but by changing the web.xml, any PHPBB2 forum can be used.


What do I need to run the example?

We tested the code on Tomcat 5.5 and used the Eclipse/MyEclipse environment for development. If you use that same environment, you can simply extract the archive, import in into Eclipse and deploy it to Tomcat. Using MyEclipse you have to enter a deploy location. This is the location where the sample application is mounted on your website. You can enter /phpbb2servlet here. If that doesn't work, edit the .mymetadata file in your project root (use the resources perspectice) and add the following attribute: context-root="/phpbb2servlet" . After making this modification, you have to restart Eclipse.

At the moment, we don't use any other IDE than Eclipse, but any documentation for how to compile and run this in other environments (e.g. netbeans) is of course welcome.

Of course, you also need access to a PHPBB2 forum. There are no special requirements for this, other than that the J2EE server must be able to reach it via a (public) URL.


How do I use the servlet in my own application?

Simply download the .jar file in the download section without the _proj or _src suffixes. Put this somewhere in the classpath of your J2EE application. This is typically WEB-INF/lib. Look at the web.xml provided with the example application and copy the servlet and servlet-mapping tags (declarations) to your own web.xml file. Naturally, you may have to adjust certain parameters for your local situation.


What are the future plans?

We intend to stabilize the code first. Initial testing confirms that it worked on our own forum, but we need to test some more situations.

We plan to implement a small Java API on top of PHPBB2 for basic tasks like adding, removing and updating users. Currently, the PHPBB2 forum and the J2EE application will get of of sync if the J2EE application allows its users to change their name and/or password. There is no mechanism for notifying PHPBB2 about these changes.

To reach this goal, we might use the standard PHPBB2 HTTP interface (e.g. just request pages with the right parameters), add a set of specially prepared PHP pages to PHPBB2 that we then call, or we might write directly to the PHPBB2 database. Naturally, only the first method works with a general, public accessible, PHPBB2 server. Feedback on what YOU think about this issue will be appreciated. :-)


Why was this implemented?

Phpbb2servlet was originally implemented as part of the M4N product. For this J2EE web application, a forum was required that intergrated nicely with M4N, both visually as functionally. Since there are not a lot of J2EE fora available, we decided to adapt the excellent PHPBB2 forum.

 
  PHPBB2servlet - Java J2EE forum intergration