wiki:WebInGnowsis

Version 1 (modified by sauermann, 18 years ago) (diff)

--

TracNav?

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.

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/

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

 ...
 </welcome-file-list>

<!-- Common JSP Core Tag Library -->
  <taglib>
    <taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
    <taglib-location>/WEB-INF/c.tld</taglib-location>
  </taglib>
  <taglib>
    <taglib-uri>http://java.sun.com/jsp/jstl/fmt</taglib-uri>
    <taglib-location>/WEB-INF/fmt.tld</taglib-location>
  </taglib>
  <taglib>
    <taglib-uri>http://java.sun.com/jsp/jstl/xml</taglib-uri>
    <taglib-location>/WEB-INF/x.tld</taglib-location>
  </taglib>

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.