Solved

URL Connection

Posted on 1997-11-14
3
160 Views
Last Modified: 2010-04-16
I am a student and I'm engaged with the dissertation at the moment.The actually problem of my work is the following:
A web-server camera is installed local over a Hub with a PC.
In the camera(an AXIS Product) is a relay. In a Browser I can simply switch the relay by input the URL :
http://cameraname/io/relayon.txt

My question:How can I switch the relay from a Java Applet?

I've tried it like this:


private synchronized void reopenURL( URL urlOpen )
{
    try
    {
      URLConnection connect = urlOpen.openConnection();
             
      connect.setDefaultAllowUserInteraction( true );
                        
        connect.setUseCaches( false );

      connect.setDoInput( true );       

      connect.connect();

      InputStream inputstream = connect.getInputStream();

      while( inputstream.read() >= 0 );
             inputstream.close();
        }
      catch( IOException e )
      {
            String m_strIOExcept = e.getMessage();
      }
}

public void setRelayOn()
{
        try
      {
      
       URL url = newURL("http","webcam",80,"/io/input.txt");
       reopenURL(url);
}
      catch (MalformedURLException m)
      {
            String test = m.getMessage();      
      }
            
This is my own written class (not exactly of course)
The method setRelayOn() is called by the Applet.
If I debug the program there is the same mistake every time.
When I reach the line connect.connect() I receive the error message "java/net/URLConnection: field url not found"!

Thanks for your help.
0
Comment
Question by:mkaufman
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
russgold earned 100 total points
ID: 1230588
If you can normally do what you want from a browser using http, just call showDocument() on your applet context:


URL cameraSwitch = new URL( "http://cameraname/io/relayon.txt" );
getAppletContext(). showDocument( cameraSwitch );
0
 

Author Comment

by:mkaufman
ID: 1230589
I,ve tried it and it works!!!!
thank you very,very much!!!!!
0
 

Author Comment

by:mkaufman
ID: 1230590
In your example, how can I prevent, that the Browser use caches?
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now