How to call equivalent of Server.CreateObject from Java

Hi,
 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)
		Response.BinaryWrite(wms.Result);
	else
		Response.Write(wms.Result);
 
	// release mapserver object
	mapserver = null;
 
	Response.End();
}

Open in new window

chrismarxAsked:
Who is Participating?

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

x
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.

e.g.

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.
0
CEHJCommented:
If 'from Java' == from JavaScript, then yes, otherwise you would need to have a Java/ActiveX bridge
0
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.
0
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?
0
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.
0
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...
0
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:
http://mapserver.gis.umn.edu/docs/howto/javamapscript
0
chrismarxAuthor Commented:
yeah, actually, i need to use this software

http://www.manifold.net/index.shtml

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

http://www.manipedia.eu/index.php?title=COM_/_External_Programming


0
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

'VBScript
 
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')
Q.Text="""
        Select * from [AAA]
 
 
 
        """
Q.Run
 
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
cset.Remove('TempQ')
 
 
doc.Save()      
doc.Close()
app.Quit()
doc==None
app==None
cset==None

Open in new window

0
Kevin CrossChief Technology OfficerCommented:
Have a meeting now, but will take a look...
0
CEHJCommented:
0

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!
0
CEHJCommented:
:-)
0
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
Java

From novice to tech pro — start learning today.