HTML pages and servlets in gnowsis

You can server HTML user interfaces and servlets using a normal web-application container. Gnowsis supports Servlet 2.3 specification using a Jetty server 4.2.22. This is equivalent to a Tomcat 4.1 server. Note: a service will only have an associated webspace, if the web.xml file exists.

If you look into the GnowsisProjectStructure you will notice where the web-pages and the other web-container related information lies: in the service/projectname/ folder. You find there the typical elements of a web-application:

  • WEB-INF - metadata
    • lib - libraries
    • classes - the compiled servlets and the compiled gnowsis code
  • web.xml - config

To add new HTML pages, put them into these folders or create a new project with similar folders:

  • yourproject/services/yourproject/

To add new servlets, program the servlet code in the application source packages. Then add the servlet-mapping definitions as usual to the web.xml file.

Embedding images in webpages

The local gnowsis server runs at, for a web-browser this looks like any webserver. So the webbrowser will allow you to embed images in your web-applications if they have URLs that point to web images, not to file images on your harddisk.

<img src="picture.jpg" />
<img src="/gnowsis-server/picture.jpg" />
<img src="" />

this is not allowed due to security restrictions in the web browser:
<img src="file:/C:/picture.jpg" />

As a workaround we provided a servlet that loads local images and returns them, it works like this:

<img src="/gnowsis-server/showimage?uri=file:/C:/picture.jpg" />
<!-- long version -->
<img src="" />

As kaukolu currently does not support HTML, use this markup


JSP Java Server Pages in Gnowsis

how to program java server pages and why stuff doesn't work as usual.

Why is JSP such a thing in gnowsis? Because we use special classloaders that kickstart the system. Our classloader lets all classes from all services see each other. Some expected default behaviour is not supported now.

How to make JSP and Taglibs run in my Service?

Look at gnowis-server, in the services/gnowsis-server/WEB-INF path you will see how the hack works:

  • you extract the taglib-descriptors (for example, in standard jar's, they are in the jar/MANIFEST directory). copy the needed .tld into the web-inf
  • you write the tld's into your web.xml file. see again in gnowsis-server how this is done
  • you insert the taglib-include into your jsp as normal.

How we did it in web.xml


<!-- Common JSP Core Tag Library -->

If you know a better way to do it in gnowsis, please tell us via the mailinglist.

How does gnowsis get JSP to run?

  • The java compiler (javacc) in tools.jar is part of the gnowsis project
  • The jsp compiler (jasper) and runtime are in the gnowsis-server/service/gnowsis-server/WEB-INF/lib path
  • all classloaders inside the services (gnowsis-server, kaukolu, enquire2006, etc) share the same classloader - the EPOSWorkspaceClassloader, so they can load each other. Additionally they have access to the 'gnowsis' classloader, which is the standard java classloader.

How can I break this?

  • if you move the javacc into the gnowsis-server, it breaks it doesn't find javacc (unknonw why)
  • if you move jasper-compiler to gnowsis, it breaks because the compiler is then loaded with the default classloader and not our EPOSWorkspaceClassloader. so leave it inside gnowsis-server
  • somehow our classloader doesn't interpret the MANIFEST things correctly, so the JSP taglibs in standard.jar are not found and cannot be used with above hack. So don't delete the taglib information from gnowsis-server/WEB-INF.
Last modified 15 years ago Last modified on 07/26/06 11:26:04