• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1037
  • Last Modified:

How to call equivalent of Server.CreateObject from Java

 I have an ASP page that creates an instance of an applications mapserver object, and then calls some of its functions. It's written in ASP, and I'm wondering whether I could do the same thing from java?
var mapserver;
mapserver = Server.CreateObject("Manifold.MapServer");
mapserver.Create(Server.MapPath("config.txt"), parameter("state", ""), Server);
// handle OGC WMS command
var wms = mapserver.CreateOgcWmsDriver();
if (wms.Handle(Request.QueryString, "http://" + Request.ServerVariables("SERVER_NAME") + Request.ServerVariables("URL"))) {
	Response.ContentType = wms.ResultContentType;
	if (wms.ResultContentType.indexOf("image/") >= 0)
	// release mapserver object
	mapserver = null;

Open in new window

  • 5
  • 5
  • 3
1 Solution
Kevin CrossChief Technology OfficerCommented:
It depends on the availability of the objects you are using in ASP as API's for Java; however, to answer your question, the equivalent in Java is to instantiate an object of the class like Manifold.MapServer.  It is the same you would do in .NET.


VB.NET ==> Dim mapserver As New Manifold.MapServer()
C#.NET ==> Manifold.MapServer mapserver = new Manifold.MapServer();
Java ==> Manifold.MapServer mapserver = new Manifold.MapServer();

Again this would need the real class/package names for API.  For example, Java's convention is to have lowercase package names versus .NET's upper/camel case style namespaces.  People do things differently, but think in general you may see something like this for same package in java: com.manifold.MapServer mapserver = new com.manifold.MapServer().

Hopefully that helps.
If 'from Java' == from JavaScript, then yes, otherwise you would need to have a Java/ActiveX bridge
Kevin CrossChief Technology OfficerCommented:
CEHJ is correct is you were meaning literally to use the ActiveX component Manifold.MapServer.  I apologize -- for some reason thought you were asking about the concept of creating objects but CEHJ's response makes more sense if like he said "Java" == JavaScript.
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

chrismarxAuthor Commented:
no, not from javascript, from a java controller. i've never tried to access the functions as you described

com.manifold.MapServer mapserver = new com.manifold.MapServer().

where does one go to see these packages?
Kevin CrossChief Technology OfficerCommented:
I was showing generically how instantiating objects work in Java.  Thought that was the question.  You will need to see if there is an API in Java for the class you are using in ASP and use that class as shown.  That was my fault that I realized after CEHJ posted.
chrismarxAuthor Commented:
no problems, yeah i've used "new" many times. so there is no api in java, there is only a .net api, its a very microsoft centric product...
Kevin CrossChief Technology OfficerCommented:
There may be similar API's, so don't get us wrong.  Just not going to be that exact ActiveX component.  

For example found this:
chrismarxAuthor Commented:
yeah, actually, i need to use this software


here are some posts that describe working with manifold from visual studio, which basically describes what i need to do, but from java


chrismarxAuthor Commented:
so i made some progress...

i tried to run the first code snippet, (saved as .vbs file) but it only opened up a cscript command window, and didn't do anything.

then i tried the second snippet from pythonWin and that worked.
so now i'm wondering what it will take to do these examples in java

Set app = CreateObject("Manifold.Application")
Set doc = app.NewDocument("c:\data\test.map", False)
MsgBox doc.ComponentSet.Count
from win32com.client import constants, Dispatch, CastTo
def setUp(mapfile):
    app = Dispatch("Manifold.Application")
    doc = app.DocumentSet.Open(mapfile,False)
    cset = doc.ComponentSet
    return app,doc,cset
#Set Up Your Global Variables and Your Map File --- Setting ReadOnly To False
print 'Open Map'
app,doc,cset = setUp("C:\RN.map")
print 'Create Query'
Q = doc.NewQuery('TempQ')
        Select * from [AAA]
QT = CastTo(Q.Table,"ITable")
print QT.RecordSet.Count
#QTR =
QTR = CastTo(QT.RecordSet,"IRecordSet")
for each in QTR:
    each = CastTo(each,"IRecord")
    print each.DataByIndex(0)
# Remove Query

Open in new window

Kevin CrossChief Technology OfficerCommented:
Have a meeting now, but will take a look...
chrismarxAuthor Commented:
i got my vbscript examples working, just need to download the latest version of the windows script host. the bridge looks good, i will look into that!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

  • 5
  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now