[mapserver-users] Java Web server with mapserver

Riccardo Cohen rcohen at dial.oleane.com
Wed Apr 25 12:11:09 EDT 2001


Hi all,
This is just a message to explain what I've done.

I make a JSP server with apache/tomcat. I use mapserver to generate the maps. But as the whole application is controled by the jsp pages, I cannot let the cgi parse my jsp pages. I needed a java class like that :

javamapserver.set_param("my_config.map");
javamapserver.set_param("my_map_to_use.shp");
javamapserver.set_param(...);
imagename=javamapserver.makethemap()

then the jsp page just have to get the image url from the javabean.

To do that, first I called the cgi-bin through a java socket. But this was not efficient because for each map I do I need to connect to apache, then apache launches mapserv, then send back the html page where I can find the image name, then I parse that name.

It worked all right but I tried to improve it. I wanted to call the main() function of mapserver directly through JNI call. This was marvelous (in the idea at least) because

- I need not to change my application. It is only the channel that changes. All the parameters still remain in the market.sym, demo.map ... Everything is unchanged
- I need not to build a whole java mapscript (anyway I do not know who to do that and even If it was already finished by Graham Sims I would need to change all my code to use it)
- Apache is no more requested
- the mapserv program (400kb) is not loaded at each request

The compilation went all right and the first execution worked. but the second made exceptions and access violation.
My debugging stopped when I understood that all works all right if I remove the lines at end of main() function that cleans everything (msFreeMap(Map); especially). And even with that, after 200 calls there is an exception.

So I choose another way : Java will load mapserv instead of apache. It works all right now and I have the 3 first advantages written above. But not the last. My java code launches mapserv with an url as parameter. This url is the same as the one that mapserver would have received through apache. I changed a little function and thats it.

Thats all, if anyone has a similar problem, I would be happy to hear him or her on the list.

Thanks to have read all that.
-- 
Riccardo Cohen

Articque
Les Roches
37230 Fondettes
France
email = rcohen at dial.oleane.com
web = http://www.articque.com
tel: +33 02 47 49 90 49
fax: +33 02 47 49 91 49



More information about the mapserver-users mailing list