| Dart Home | PowerTCP Web for ActiveX | Custom Development | Reply | PowerTCP Web for ActiveX Topics | Forums |
| Author | Forum: PowerTCP Web for ActiveX Topic: java.lang.OutOfMemory Error in Visual J++ |
| DCrammond From: Engadine, Australia Posts: 2 Member Since: 06/12/02 |
posted June 12, 2002 10:50 PM Hi, I'm having some porblems using the WebTool as part of a control. An extract of the code I'm using is below. The problem I am having is the first page I bring back works fine, but the second time I call getPage() it throws an out of memory error when it calls setUrl(). I am using the class below as a singleton in my main communication class. Has anyone run into this problem before, or is there any examples in J++?? private synchronized void logIn() { try { http1.setUrl(loginURL); Variant requestParameters = new Variant(); Variant requestHeaders = new Variant(); Variant responseData = new Variant(Variant.VariantByref|Variant.VariantString, ""); Variant responseHeaders = new Variant(Variant.VariantString, ""); String username = new String(""); String password = new String(""); http1.Post(requestParameters,requestHeaders,responseData,responseHeaders,username,password); isLoggedIn = true; } catch(Exception e) { e.printStackTrace(); } } public byte[] getPage(String url, String body) { byte[] buffer = null; try { if(!isLoggedIn) { MessageBox.show("!isLoggedIn"); logIn(); } http1.setUrl(url); Variant requestParameters = new Variant(body); Variant requestHeaders = new Variant(); SafeArray array = new SafeArray(Variant.VariantByte); Variant responseData = new Variant(array, true); Variant responseHeaders = new Variant(Variant.VariantString, ""); String username = new String(""); String password = new String(""); http1.Post(requestParameters,requestHeaders,responseData,responseHeaders,username,password); buffer = responseData.toSafeArray().toByteArray(); MessageBox.show(new String(buffer)); } catch(Exception e) { e.printStackTrace(); } return buffer; } Container components = new Container(); dartweb.Http.Http http1 = new dartweb.Http.Http(); private void initForm() { IResourceManager resources = new ResourceManager(this, "WebCommunication"); this.setSize(new Point(300, 300)); this.setText("WebCommunication"); components.add(http1, "http1"); http1.setLocation(new Point(72, 152)); http1.setSize(new Point(75, 75)); http1.setTabIndex(0); http1.setOcxState((AxHost.State)resources.getObject("http1_ocxState")); this.setNewControls(new Control[] { http1}); http1.begin(); } |
Jon Belanger![]() From: Rome, NY USA Posts: 310 Member Since: 06/10/02 |
posted June 13, 2002 10:53 AM Try using DartStreams instead of Variants to get data back from the post. We were having problems with this working with .NET and JavaScript because of passing in variables by reference. The solution to this problem was to make those paramters that were strings or byte arrays into DartStream objects. We don't have any examples of our controls in J++. J. Belanger |
Jon Belanger![]() From: Rome, NY USA Posts: 310 Member Since: 06/10/02 |
posted June 13, 2002 11:37 AM I copy pasted your code and reproduced the application. I get the data everytime. The only thing I didn't do was actually login as some one, I left that string blank. I didn't get any problems, and I get the data everytime by using variants. Are you using the most recent version of the tool? J. Belanger |
| DCrammond From: Engadine, Australia Posts: 2 Member Since: 06/12/02 |
posted June 13, 2002 6:32 PM I was using the 30 day trial version... I only downloaded it 2 days ago. I haven't seen an example of how to use DartStreams with Post... would you mind posting just a short example here? |
Jon Belanger![]() From: Rome, NY USA Posts: 310 Member Since: 06/10/02 |
posted June 14, 2002 8:30 AM I can post an example, but actually the only example I've seen came from the code you gave me in the previous post. I just copy pasted that code and added some functional code to a new project and everything worked fine. In short, I can't seem to reproduce your error. Basically, I have a command button that calls the getPage function, if I just keep clicking it works every time. Let me know if the action that you are using to produce the error is something different. Thanks. J. Belanger |
| Reply | PowerTCP Web for ActiveX Topics | Forums |
This site is powered by
PowerTCP WebServer for ActiveX
|