How to do HTTP binding for Openfire plugin

I’m using Openfire as the chat server for my company. And now I need to create a plugin for Openfire.

As I can see from other plugins, they can have HTTP binding to themself through port 7070. For example: http://example.com:7070/redfire where redfire is the name of the plugin.

The name of my plugin is toplug, so I want to be able to access the JSP pages of my plugin through:http://example.com:7070/toplug/index.jsp where ‘index.jsp’ is some example page.

But when I try to access my JSP pages through port 7070, the Jetty server (on which Openfire runs) always reports error 404 ‘page not found’. I guess this is because the binding to my folder which contains JSP pages hasn’t been set. How to do this binding thing please?

1 Like

You do not need a plugin to access the web service for the http bing port. Just put your web pages in a folder under

OPENFIRE_HOME/openfire/resources/spank

and access with

http://your_server:7070/your_folder/your_page.html

Note that Openfire does not compile JSP pages unless you replace jasper-xxxx.jar files in the lib folder

If you still want to create a jetty web context (application) from your plugin, see source code of Redfire plugin

import org.eclipse.jetty.server.handler.ContextHandlerCollection;
import org.eclipse.jetty.webapp.WebAppContext; ..... public void initializePlugin(PluginManager manager, File pluginDirectory)
  {
      ContextHandlerCollection contexts = HttpBindManager.getInstance().getContexts();
      context = new WebAppContext(contexts, pluginDirectory.getPath(), "/" + NAME);
      context.setWelcomeFiles(new String[]{"index.html"})
1 Like

thanks dele, however, by this method i can only access pure html or data files.

is it able to access JSP files also?

i put the JSP files in my plugin folder, but [ant plugins] doesn’t compile it at all.

it only compiles those JSP files in ‘my-plugin/src/web’, these files are for admin console,

not for opening through public port 7070.

this thread solves the problem by allowing public access thru’ port 9090

  1. in your plugin, you need the following:

private static final String URL = “userservice/sign-in.jsp”; // replace with your plugin/your.jsp

In init() function I have to add:
AuthCheckFilter.addExclude(URL);

And in destroy():

AuthCheckFilter.removeExclude(URL);

  1. In the .jsp page, you need the following:

If you don’t have this meta tag in your jsp, you will get the following error:

Exception:

java.lang.NullPointerException