Solved

URL Connection

Posted on 1997-11-14
3
163 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
json example 39 130
splitOdd10 challenge 5 74
Saving Tweets with emojis using Twitter4J in a Mysql table 2 73
simple java question 3 44
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
The viewer will learn how to implement Singleton Design Pattern in Java.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

932 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

15 Experts available now in Live!

Get 1:1 Help Now