# Code Execution Upon Server Startup

**URL:** <https://forum.servoy.com/t/code-execution-upon-server-startup/13509>\
**Category:** Classic Servoy\
**Created:** [January 31, 2011, 10:51pm UTC](https://forum.servoy.com/t/code-execution-upon-server-startup/13509 "2011-01-31T22:51:45Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![erikd](https://avatars.discourse-cdn.com/v4/letter/e/b782af/32.png) [@erikd](https://forum.servoy.com/u/erikd)\
**Post date:** [January 31, 2011, 10:51pm UTC](https://forum.servoy.com/t/code-execution-upon-server-startup/13509/1 "2011-01-31T22:51:45Z")

</div>

Hi, does Servoy execute or run a method like onApplicationStartup at initial startup of solution in Application Server? I need to initialize a HashMap before the Servoy application is ready to be used by clients/users.

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [February 1, 2011, 9:04am UTC](https://forum.servoy.com/t/code-execution-upon-server-startup/13509/2 "2011-02-01T09:04:14Z")

</div>

Hi Erik,

You could use a batch processor (i.e. headless client) for this that launches once, does it’s thing and quits (all by your own code).

Hope this helps.

---

<div class="post-metadata">

**Author:** ![erikd](https://avatars.discourse-cdn.com/v4/letter/e/b782af/32.png) [@erikd](https://forum.servoy.com/u/erikd)\
**Post date:** [February 2, 2011, 5:25am UTC](https://forum.servoy.com/t/code-execution-upon-server-startup/13509/3 "2011-02-02T05:25:43Z")

</div>

> ROCLASI:  
> Hi Erik,
> 
> You could use a batch processor (i.e. headless client) for this that launches once, does it’s thing and quits (all by your own code).
> 
> Hope this helps.

Thanks for the reply. So how does this work? I’d like to start a headless client automatically when I start the application server. Will I set the headless client through the web.xml like the code below?

```auto
  <servlet>
    <servlet-name>ExecutionServlet</servlet-name>
    <servlet-class>com.x.ExecutionServlet</servlet-class>
    <init-param>
      <param-name>startHeadlessClient</param-name>
      <param-value>1</param-value>
    </init-param>
    <load-on-startup>3</load-on-startup>
  </servlet>

```

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [February 2, 2011, 5:35am UTC](https://forum.servoy.com/t/code-execution-upon-server-startup/13509/4 "2011-02-02T05:35:03Z")

</div>

Hi Erik,

You don’t have to dig into any config files. Instead you go to the Servoy-admin pages and in the Batchprocessors page you can create a new batchprocessor. At the top of this page you tell Servoy to load these batchprocessors when the server starts (or not).

Hope this helps.

---

<div class="post-metadata">

**Author:** ![erikd](https://avatars.discourse-cdn.com/v4/letter/e/b782af/32.png) [@erikd](https://forum.servoy.com/u/erikd)\
**Post date:** [February 2, 2011, 5:56am UTC](https://forum.servoy.com/t/code-execution-upon-server-startup/13509/5 "2011-02-02T05:56:07Z")

</div>

Thanks for the quick reply.

Can I access a variable such as a HashMap in a Headless client from Servoy smart client (sc) or web client (wc)? I’d like to retrieve some details from a Headless client at startup and share these information to sc and wc.

---

<div class="post-metadata">

**Author:** ![rgansevles](https://avatars.discourse-cdn.com/v4/letter/r/3d9bf3/32.png) [@rgansevles](https://forum.servoy.com/u/rgansevles)\
**Post date:** [February 7, 2011, 8:59am UTC](https://forum.servoy.com/t/code-execution-upon-server-startup/13509/6 "2011-02-07T08:59:04Z")

</div>

Erik,

If you want to share data between clients you can do that via a table.  
If you want this only in memory, you could create a plugin that does this, but this requires some java programming.  
Your plugin would need a server and a client part to work in SC as well.

```auto
plugins.static.setValue(key, value)
plugins.static.getValue(key)

```

Rob

---

<div class="post-metadata">

**Author:** ![erikd](https://avatars.discourse-cdn.com/v4/letter/e/b782af/32.png) [@erikd](https://forum.servoy.com/u/erikd)\
**Post date:** [February 7, 2011, 9:45pm UTC](https://forum.servoy.com/t/code-execution-upon-server-startup/13509/7 "2011-02-07T21:45:57Z")

</div>

> rgansevles:  
> Erik,
> 
> If you want to share data between clients you can do that via a table.  
> If you want this only in memory, you could create a plugin that does this, but this requires some java programming.  
> Your plugin would need a server and a client part to work in SC as well.
> 
> ```auto
> plugins.static.setValue(key, value)
> 
> ```

plugins.static.getValue(key)

> ```auto
> 
> Rob
> 
> ```

Thanks Rob. I know Java/JEE programming. Do you have a tutorial for creating server-side plugins? I read the client part already.

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [February 8, 2011, 7:56am UTC](https://forum.servoy.com/t/code-execution-upon-server-startup/13509/8 "2011-02-08T07:56:37Z")

</div>

You can also use our [UserManager plugin](http://www.servoy-plugins.de). It already includes client and/or server HashMaps neatly wrapped in a JSHashMap.
