Solved

URL Connection

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
tomcat administrtor 12 59
Problem to Alipay 10 42
Html Table Looping (part 2) 5 27
What browser will run Java? 7 49
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

808 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