creapage.net

HOWTO - Sashipa development

 How to create a servlet with Sashipa-Melba.

You already have a Sashipa stand-alone application. You wish to deploy it with a client-servlet-database architecture.

In a client-servlet-database architecture, the client software doesn't directly access to the database. It talk with the servlet in HTTP, then the servlet works on the database. This architecture enables multi-users management (only one client can access to the same card for modifications). This architecture can be used for deploy applets too, because an applet can't directly access a dbms.

Before to begin, you'll need a servlets container, like Tomcat from the Apache Jakarta project. Install it before. If you use a JDBC driver, you have to configure your servlet container for adding the jdbc driver in its classpath. Under Tomcat you just have to create a sub-directory "lib" in the directory "WEB-INF/" of your application, then you can copy the jar files of your driver.

Moreover, you have to set the variable LIB_SERVLET in the file '<melbalab-home>/s2m' (Linux) or '<melbalab-home>/s2m.bat' (Windows).

Now, let's go.

Here is the code to modify in your Sashipa source file (example with Tomcat):

<serverSet>
  <server type='servlet'>

    ... element dbConnection ...

    ... element logStorage ...

    <specificToServlet copySourceOfApplication='yes'>
      <servletResourceName>DemoContactServlet</servletResourceName>
      <servletUrl>
        http://mytomcatserver:8080/examples/servlet/DemoContactServlet
      </servletUrl>
    </specificToServlet>

  </server>

  <!-- ... -->
</serverSet>

Remark: the attribute copySourceOfApplication is optional. It means that the source of your Sashipa application will be copied with the generated Servlet files, for backup.

Take care to use the network name (or the ip adress) of the server. If you use localhost then the client software will works on your computer only.

Rebuild. Your servlet is created.

You yave to copy all the servlet files in the right place, in your server of servlets

Now you can check if your servlet is available from the servlet server. Open a browser and try the url that is written in the element <serverConnectionString>. If there isn't any response (404 not found or nothing or 'no resources'...) then you can't continue:

Remark: you have to update the servlet each time something is modified in the <environment> part - and each time you change version of the melbalab. But when you modify a GUI component (a form or other), then the servlet isn't modified. So you don't need to update it.

Now you can run your jar file: you are in client - servlet - database mode :o) For checking that, open two instances of your client application and go on the same card. The card in the second instance will be read-only.

© Copyright 2003 Sashipa-Melba Team. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License as much as this note clearly appears.