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

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

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\", 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:\")
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...

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.